php curl_multi_thread not working properly
This is the code I am using
function initiate_curl($row, $mh)
$ch = curl_init();
$url = 'http://openapi.gbis.go.kr/ws/rest/busarrivalservice'; /*URL*/
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
curl_setopt($ch, CURLOPT_URL, $url . $queryParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_multi_add_handle($mh, $ch);
return $ch;
$mh = curl_multi_init();
$arr = array();
$rows = array();
while ($row = mysqli_fetch_array($query))
array_push($arr, initiate_curl($row, $mh));
array_push($rows, $row);
$running = null;
do
curl_multi_exec($mh, $running);
while ($running);
foreach($arr as $curl) curl_multi_remove_handle($mh, $curl);
curl_multi_close($mh);
foreach($arr as $key=>$curl)
**DO MY WORK
Most of the times it works fine but sometimes I get null as a result of the query. However, when I go to the API through typing the url, it returns the value perfectly. Also, the object that is returned as null changes any time so I'm 100% sure that this is the fault of my curl_multi part.
Am I implementing this wrong or is it simply not that reliable to use?
php curl curl-multi
add a comment |
This is the code I am using
function initiate_curl($row, $mh)
$ch = curl_init();
$url = 'http://openapi.gbis.go.kr/ws/rest/busarrivalservice'; /*URL*/
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
curl_setopt($ch, CURLOPT_URL, $url . $queryParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_multi_add_handle($mh, $ch);
return $ch;
$mh = curl_multi_init();
$arr = array();
$rows = array();
while ($row = mysqli_fetch_array($query))
array_push($arr, initiate_curl($row, $mh));
array_push($rows, $row);
$running = null;
do
curl_multi_exec($mh, $running);
while ($running);
foreach($arr as $curl) curl_multi_remove_handle($mh, $curl);
curl_multi_close($mh);
foreach($arr as $key=>$curl)
**DO MY WORK
Most of the times it works fine but sometimes I get null as a result of the query. However, when I go to the API through typing the url, it returns the value perfectly. Also, the object that is returned as null changes any time so I'm 100% sure that this is the fault of my curl_multi part.
Am I implementing this wrong or is it simply not that reliable to use?
php curl curl-multi
there is a much better way to write that url with the http_build_query function, check this: pastebin.com/raw/xjEJAGqr
– hanshenrik
Nov 14 '18 at 0:19
the url is fine I'm having problems fetching the data
– Seong Min Choo
Nov 14 '18 at 0:21
also your curl_multi_exec loop will use 100% cpu (of 1 core) for no good reason, add a curl_multi_select in there to keep your cpu usage reasonable
– hanshenrik
Nov 14 '18 at 0:22
add CURLOPT_VERBOSE logging to each curl handle, and when you get a NULL, dump the verbose log of that curl handle, and post the verbose log, the log may say why it returned null
– hanshenrik
Nov 14 '18 at 0:26
can you explain more on that sir? I am not that familiar with php..
– Seong Min Choo
Nov 14 '18 at 0:31
add a comment |
This is the code I am using
function initiate_curl($row, $mh)
$ch = curl_init();
$url = 'http://openapi.gbis.go.kr/ws/rest/busarrivalservice'; /*URL*/
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
curl_setopt($ch, CURLOPT_URL, $url . $queryParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_multi_add_handle($mh, $ch);
return $ch;
$mh = curl_multi_init();
$arr = array();
$rows = array();
while ($row = mysqli_fetch_array($query))
array_push($arr, initiate_curl($row, $mh));
array_push($rows, $row);
$running = null;
do
curl_multi_exec($mh, $running);
while ($running);
foreach($arr as $curl) curl_multi_remove_handle($mh, $curl);
curl_multi_close($mh);
foreach($arr as $key=>$curl)
**DO MY WORK
Most of the times it works fine but sometimes I get null as a result of the query. However, when I go to the API through typing the url, it returns the value perfectly. Also, the object that is returned as null changes any time so I'm 100% sure that this is the fault of my curl_multi part.
Am I implementing this wrong or is it simply not that reliable to use?
php curl curl-multi
This is the code I am using
function initiate_curl($row, $mh)
$ch = curl_init();
$url = 'http://openapi.gbis.go.kr/ws/rest/busarrivalservice'; /*URL*/
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
curl_setopt($ch, CURLOPT_URL, $url . $queryParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_multi_add_handle($mh, $ch);
return $ch;
$mh = curl_multi_init();
$arr = array();
$rows = array();
while ($row = mysqli_fetch_array($query))
array_push($arr, initiate_curl($row, $mh));
array_push($rows, $row);
$running = null;
do
curl_multi_exec($mh, $running);
while ($running);
foreach($arr as $curl) curl_multi_remove_handle($mh, $curl);
curl_multi_close($mh);
foreach($arr as $key=>$curl)
**DO MY WORK
Most of the times it works fine but sometimes I get null as a result of the query. However, when I go to the API through typing the url, it returns the value perfectly. Also, the object that is returned as null changes any time so I'm 100% sure that this is the fault of my curl_multi part.
Am I implementing this wrong or is it simply not that reliable to use?
php curl curl-multi
php curl curl-multi
asked Nov 13 '18 at 22:59
Seong Min ChooSeong Min Choo
477
477
there is a much better way to write that url with the http_build_query function, check this: pastebin.com/raw/xjEJAGqr
– hanshenrik
Nov 14 '18 at 0:19
the url is fine I'm having problems fetching the data
– Seong Min Choo
Nov 14 '18 at 0:21
also your curl_multi_exec loop will use 100% cpu (of 1 core) for no good reason, add a curl_multi_select in there to keep your cpu usage reasonable
– hanshenrik
Nov 14 '18 at 0:22
add CURLOPT_VERBOSE logging to each curl handle, and when you get a NULL, dump the verbose log of that curl handle, and post the verbose log, the log may say why it returned null
– hanshenrik
Nov 14 '18 at 0:26
can you explain more on that sir? I am not that familiar with php..
– Seong Min Choo
Nov 14 '18 at 0:31
add a comment |
there is a much better way to write that url with the http_build_query function, check this: pastebin.com/raw/xjEJAGqr
– hanshenrik
Nov 14 '18 at 0:19
the url is fine I'm having problems fetching the data
– Seong Min Choo
Nov 14 '18 at 0:21
also your curl_multi_exec loop will use 100% cpu (of 1 core) for no good reason, add a curl_multi_select in there to keep your cpu usage reasonable
– hanshenrik
Nov 14 '18 at 0:22
add CURLOPT_VERBOSE logging to each curl handle, and when you get a NULL, dump the verbose log of that curl handle, and post the verbose log, the log may say why it returned null
– hanshenrik
Nov 14 '18 at 0:26
can you explain more on that sir? I am not that familiar with php..
– Seong Min Choo
Nov 14 '18 at 0:31
there is a much better way to write that url with the http_build_query function, check this: pastebin.com/raw/xjEJAGqr
– hanshenrik
Nov 14 '18 at 0:19
there is a much better way to write that url with the http_build_query function, check this: pastebin.com/raw/xjEJAGqr
– hanshenrik
Nov 14 '18 at 0:19
the url is fine I'm having problems fetching the data
– Seong Min Choo
Nov 14 '18 at 0:21
the url is fine I'm having problems fetching the data
– Seong Min Choo
Nov 14 '18 at 0:21
also your curl_multi_exec loop will use 100% cpu (of 1 core) for no good reason, add a curl_multi_select in there to keep your cpu usage reasonable
– hanshenrik
Nov 14 '18 at 0:22
also your curl_multi_exec loop will use 100% cpu (of 1 core) for no good reason, add a curl_multi_select in there to keep your cpu usage reasonable
– hanshenrik
Nov 14 '18 at 0:22
add CURLOPT_VERBOSE logging to each curl handle, and when you get a NULL, dump the verbose log of that curl handle, and post the verbose log, the log may say why it returned null
– hanshenrik
Nov 14 '18 at 0:26
add CURLOPT_VERBOSE logging to each curl handle, and when you get a NULL, dump the verbose log of that curl handle, and post the verbose log, the log may say why it returned null
– hanshenrik
Nov 14 '18 at 0:26
can you explain more on that sir? I am not that familiar with php..
– Seong Min Choo
Nov 14 '18 at 0:31
can you explain more on that sir? I am not that familiar with php..
– Seong Min Choo
Nov 14 '18 at 0:31
add a comment |
1 Answer
1
active
oldest
votes
(this is not an answer, but too much to be posted as comments)
first off, this is a shitty way to write a URL-encoded query string in PHP:
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
PHP has a function specifically dedicated to writing URL-encoded query strings, called http_build_query
, and the code would look much better if written as:
$queryParams = http_build_query(array(
'serviceKey' => 'SERVICE API KEY',
'stationId' => $row['stId'],
'routeId' => $row['busRouteId'],
'staOrder' => $row['seq']
));
also, curl_multi_exec is an async function, it will return as soon as curl is waiting for io, meaning that calling curl_multi_exec until $running becomes false will use 100% cpu (of 1 cpu core), which is completely unnecessary, and some shared-webhost providers may even kill your script for using too much cpu .. use curl_multi_select
to sleep until curl_multi_exec has something to do (which will turn the CPU usage down to 1-2% instead of 100%), try this:
$running = null;
for(;;)
curl_multi_exec($mh, $running);
if(!$running)
break;
curl_multi_select($mh);
sometimes I get null as a result of the query
what query are you talking about? do you mean you get NULL from the mysql query? eg that mysqli_fetch_array
sometimes return NULL? in which case you need to check out the implementation of mysqli_fetch_array
, it's not a standard PHP function, it's userland-php code. (however, the similarly named mysqli_result::fetch_array
is a normal core PHP function, and when that function returns NULL, it means you've already fetched the last result - or if it returns NULL on the first execution, it means there was 0 results in total)
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290777%2fphp-curl-multi-thread-not-working-properly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
(this is not an answer, but too much to be posted as comments)
first off, this is a shitty way to write a URL-encoded query string in PHP:
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
PHP has a function specifically dedicated to writing URL-encoded query strings, called http_build_query
, and the code would look much better if written as:
$queryParams = http_build_query(array(
'serviceKey' => 'SERVICE API KEY',
'stationId' => $row['stId'],
'routeId' => $row['busRouteId'],
'staOrder' => $row['seq']
));
also, curl_multi_exec is an async function, it will return as soon as curl is waiting for io, meaning that calling curl_multi_exec until $running becomes false will use 100% cpu (of 1 cpu core), which is completely unnecessary, and some shared-webhost providers may even kill your script for using too much cpu .. use curl_multi_select
to sleep until curl_multi_exec has something to do (which will turn the CPU usage down to 1-2% instead of 100%), try this:
$running = null;
for(;;)
curl_multi_exec($mh, $running);
if(!$running)
break;
curl_multi_select($mh);
sometimes I get null as a result of the query
what query are you talking about? do you mean you get NULL from the mysql query? eg that mysqli_fetch_array
sometimes return NULL? in which case you need to check out the implementation of mysqli_fetch_array
, it's not a standard PHP function, it's userland-php code. (however, the similarly named mysqli_result::fetch_array
is a normal core PHP function, and when that function returns NULL, it means you've already fetched the last result - or if it returns NULL on the first execution, it means there was 0 results in total)
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
add a comment |
(this is not an answer, but too much to be posted as comments)
first off, this is a shitty way to write a URL-encoded query string in PHP:
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
PHP has a function specifically dedicated to writing URL-encoded query strings, called http_build_query
, and the code would look much better if written as:
$queryParams = http_build_query(array(
'serviceKey' => 'SERVICE API KEY',
'stationId' => $row['stId'],
'routeId' => $row['busRouteId'],
'staOrder' => $row['seq']
));
also, curl_multi_exec is an async function, it will return as soon as curl is waiting for io, meaning that calling curl_multi_exec until $running becomes false will use 100% cpu (of 1 cpu core), which is completely unnecessary, and some shared-webhost providers may even kill your script for using too much cpu .. use curl_multi_select
to sleep until curl_multi_exec has something to do (which will turn the CPU usage down to 1-2% instead of 100%), try this:
$running = null;
for(;;)
curl_multi_exec($mh, $running);
if(!$running)
break;
curl_multi_select($mh);
sometimes I get null as a result of the query
what query are you talking about? do you mean you get NULL from the mysql query? eg that mysqli_fetch_array
sometimes return NULL? in which case you need to check out the implementation of mysqli_fetch_array
, it's not a standard PHP function, it's userland-php code. (however, the similarly named mysqli_result::fetch_array
is a normal core PHP function, and when that function returns NULL, it means you've already fetched the last result - or if it returns NULL on the first execution, it means there was 0 results in total)
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
add a comment |
(this is not an answer, but too much to be posted as comments)
first off, this is a shitty way to write a URL-encoded query string in PHP:
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
PHP has a function specifically dedicated to writing URL-encoded query strings, called http_build_query
, and the code would look much better if written as:
$queryParams = http_build_query(array(
'serviceKey' => 'SERVICE API KEY',
'stationId' => $row['stId'],
'routeId' => $row['busRouteId'],
'staOrder' => $row['seq']
));
also, curl_multi_exec is an async function, it will return as soon as curl is waiting for io, meaning that calling curl_multi_exec until $running becomes false will use 100% cpu (of 1 cpu core), which is completely unnecessary, and some shared-webhost providers may even kill your script for using too much cpu .. use curl_multi_select
to sleep until curl_multi_exec has something to do (which will turn the CPU usage down to 1-2% instead of 100%), try this:
$running = null;
for(;;)
curl_multi_exec($mh, $running);
if(!$running)
break;
curl_multi_select($mh);
sometimes I get null as a result of the query
what query are you talking about? do you mean you get NULL from the mysql query? eg that mysqli_fetch_array
sometimes return NULL? in which case you need to check out the implementation of mysqli_fetch_array
, it's not a standard PHP function, it's userland-php code. (however, the similarly named mysqli_result::fetch_array
is a normal core PHP function, and when that function returns NULL, it means you've already fetched the last result - or if it returns NULL on the first execution, it means there was 0 results in total)
(this is not an answer, but too much to be posted as comments)
first off, this is a shitty way to write a URL-encoded query string in PHP:
$queryParams = '?' . urlencode('serviceKey') . "SERVICE API KEY"; /*Service Key*/
$queryParams .= '&' . urlencode('stationId') . '=' . urlencode($row['stId']); /**/
$queryParams .= '&' . urlencode('routeId') . '=' . urlencode($row['busRouteId']); /*노선ID*/
$queryParams .= '&' . urlencode('staOrder') . '=' . urlencode($row['seq']);
PHP has a function specifically dedicated to writing URL-encoded query strings, called http_build_query
, and the code would look much better if written as:
$queryParams = http_build_query(array(
'serviceKey' => 'SERVICE API KEY',
'stationId' => $row['stId'],
'routeId' => $row['busRouteId'],
'staOrder' => $row['seq']
));
also, curl_multi_exec is an async function, it will return as soon as curl is waiting for io, meaning that calling curl_multi_exec until $running becomes false will use 100% cpu (of 1 cpu core), which is completely unnecessary, and some shared-webhost providers may even kill your script for using too much cpu .. use curl_multi_select
to sleep until curl_multi_exec has something to do (which will turn the CPU usage down to 1-2% instead of 100%), try this:
$running = null;
for(;;)
curl_multi_exec($mh, $running);
if(!$running)
break;
curl_multi_select($mh);
sometimes I get null as a result of the query
what query are you talking about? do you mean you get NULL from the mysql query? eg that mysqli_fetch_array
sometimes return NULL? in which case you need to check out the implementation of mysqli_fetch_array
, it's not a standard PHP function, it's userland-php code. (however, the similarly named mysqli_result::fetch_array
is a normal core PHP function, and when that function returns NULL, it means you've already fetched the last result - or if it returns NULL on the first execution, it means there was 0 results in total)
answered Nov 14 '18 at 11:08
hanshenrikhanshenrik
9,78921738
9,78921738
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
add a comment |
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
thank you but it's not the mysqli_fetch_array that is causing trouble it's the curl_exec part that is triggering the error
– Seong Min Choo
Nov 14 '18 at 23:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290777%2fphp-curl-multi-thread-not-working-properly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
there is a much better way to write that url with the http_build_query function, check this: pastebin.com/raw/xjEJAGqr
– hanshenrik
Nov 14 '18 at 0:19
the url is fine I'm having problems fetching the data
– Seong Min Choo
Nov 14 '18 at 0:21
also your curl_multi_exec loop will use 100% cpu (of 1 core) for no good reason, add a curl_multi_select in there to keep your cpu usage reasonable
– hanshenrik
Nov 14 '18 at 0:22
add CURLOPT_VERBOSE logging to each curl handle, and when you get a NULL, dump the verbose log of that curl handle, and post the verbose log, the log may say why it returned null
– hanshenrik
Nov 14 '18 at 0:26
can you explain more on that sir? I am not that familiar with php..
– Seong Min Choo
Nov 14 '18 at 0:31