Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP curl_multi_getcontent returns null
    primarykey
    data
    text
    <p>I have been following this tutorial on how to use <code>curl_multi</code>. <a href="http://arguments.callee.info/2010/02/21/multiple-curl-requests-with-php/" rel="noreferrer">http://arguments.callee.info/2010/02/21/multiple-curl-requests-with-php/</a></p> <p>I can't tell what I am doing wrong, but <code>curl_multi_getcontent</code> is returning null. It is suppose to return JSON. I know it is not the mysql call as I had it working with a while loop and standard <code>curl_exec</code>, but The page was taking too long to load. (I've changed some of the setopt details for security)</p> <p><strong>Relevant PHP Code snippet. I do close the while loop in the end.</strong> </p> <pre><code>$i = 0; $ch = array(); $mh = curl_multi_init(); while($row = $result-&gt;fetch_object()){ $ch[$i] = curl_init(); curl_setopt($ch[$i], CURLOPT_CAINFO, 'cacert.pem'); curl_setopt($ch[$i], CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true); curl_setopt($ch[$i], CURLOPT_URL, 'https://mysite.com/search/'.$row-&gt;username.'/'); curl_multi_add_handle($mh, $ch[$i]); $i++; } $running = 0; do { curl_multi_exec($mh, $running); } while ($running &gt; 0); $result-&gt;data_seek(0); $i = 0; while ($row = $result-&gt;fetch_object()) { $data = curl_multi_getcontent($ch[$i]); $json_data = json_decode($data); var_dump($json_data); </code></pre> <p><strong>EDIT</strong></p> <p>Here is the code that currently works, but causes the page to load too slowly</p> <pre><code>$ch = curl_init(); curl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem'); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); while($row = $result-&gt;fetch_object()){ curl_setopt($ch, CURLOPT_URL, 'https://mysite.com/search/'.$row-&gt;username.'/'); $data = curl_exec($ch); $json_data = json_decode($data); var_dump($json_data); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload