# Php curl code using hubspot api works fine for multiple orders, but sometimes fails suddenly without

**URL:** <https://community.hubspot.com/t/php-curl-code-using-hubspot-api-works-fine-for-multiple-orders-but-sometimes-fails-suddenly-without/34597>\
**Category:** APIs & Integrations\
**Tags:** php\
**Created:** [March 26, 2021, 1:55pm UTC](https://community.hubspot.com/t/php-curl-code-using-hubspot-api-works-fine-for-multiple-orders-but-sometimes-fails-suddenly-without/34597 "2021-03-26T13:55:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kkdeen005](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kkdeen005/32/79091_2.png) [@kkdeen005](https://community.hubspot.com/u/kkdeen005)\
**Post date:** [March 26, 2021, 1:55pm UTC](https://community.hubspot.com/t/php-curl-code-using-hubspot-api-works-fine-for-multiple-orders-but-sometimes-fails-suddenly-without/34597/1 "2021-03-26T13:55:50Z")

</div>

I am trying the following Curl related code which works fine for 800+ orders but fails suddenly without any response.

```lia-code-sample
//PERFORM POST REQUEST
$post_json = json_encode($order);
$endpoint = 'https://api.hubapi.com/deals/v1/deal';
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_TIMEOUT,15);
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
@curl_setopt($ch, CURLOPT_NOSIGNAL, 1);

 @curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 'Content-Type: application/json',
 "Authorization: Bearer " . $this->access_token
 ));
 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 $this->log("1");
 $response = @curl_exec($ch);
 $this->log("2");

 $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
 $curl_errors = curl_error($ch);

 @curl_close($ch);

```

The issue I am facing currently is that, Order Sync stops abruptly after sometime while CREATING NEW Orders to Hubspot API from Shopware 5.

It always stops in a CURL request. There is no response at all from the curl\_exec() statement.

`$response = @curl_exec($ch);`

The code does not move ahead of that line.

```lia-code-sample
 $this->log("1");
 $response = @curl_exec($ch);
 $this->log("2");

```

So in the code above “1” is printed, but “2” is not printed in the case when there is an issue.

The order sync does process around 800+ order everytime.

The sync doesn’t fail at any particular order, it stops at random orders.

Mostly it stops somewhere after 15- 20 minutes of run.

We have tried several debugging techniques but nothing seems to be working as if now.

We have tried Cron parameters and PHP settings.  
--  
Have modified PHP.ini file to set max execution time to a large value of 1 hour. But Have not restart PHP from pleask.

Have used these two in PHP code:

```lia-code-sample
set_time_limit(0);
ignore_user_abort(true);

```

curl settings tried are:

```lia-code-sample
@curl_setopt($ch, CURLOPT_TIMEOUT,15);
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
@curl_setopt($ch, CURLOPT_NOSIGNAL, 1);

```

Please help.

---

<div class="post-metadata">

**Author:** ![tominal](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tominal/32/73018_2.png) [@tominal](https://community.hubspot.com/u/tominal)\
**Post date:** [March 26, 2021, 6:21pm UTC](https://community.hubspot.com/t/php-curl-code-using-hubspot-api-works-fine-for-multiple-orders-but-sometimes-fails-suddenly-without/34597/2 "2021-03-26T18:21:45Z")

</div>

Using @ ignores errors. Try removing those characters and see if you get an output.  
I would also keep in mind the rate limits involved with the v1 API: [https://legacydocs.hubspot.com/apps/api\_guideline](https://legacydocs.hubspot.com/apps/api_guideline)s  
Hope that helps.
