Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP and Curl not working for particular url
    primarykey
    data
    text
    <p>I have a PHP script that uses Curl to get the number of tweets about our URLs; using this URL as an example:</p> <p><a href="http://urls.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com" rel="nofollow">http://urls.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com</a></p> <p>Also, I'm using Phil Sturgeon's Curl library for CodeIgniter to perform the gets: <a href="https://github.com/philsturgeon/codeigniter-curl" rel="nofollow">https://github.com/philsturgeon/codeigniter-curl</a></p> <p>When I run the script locally, the script runs fine. However, when I deploy it to our production environment, it breaks as soon as it tries to do a get on the above Twitter URL.</p> <p>Here's the strange thing. I perform a similar like count retrieval for the same base URL from the Facebook Graph and it works on the production servers. See the example code below:</p> <pre><code> $fb_get_url = "http://graph.facebook.com/?ids=http://stackoverflow.com"; $twitter_get_url = "http://urls.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com"; $fb_response_json = $this-&gt;curl-&gt;simple_get($fb_get_url, array(CURLOPT_CONNECTTIMEOUT =&gt; 10, CURLOPT_FAILONERROR =&gt; true)); $twitter_response_json = $this-&gt;curl-&gt;simple_get($twitter_get_url, array(CURLOPT_CONNECTTIMEOUT =&gt; 10, CURLOPT_FAILONERROR =&gt; true)); </code></pre> <p>simple_get works fine with $fb_get_url. However, I seem to be getting an error when I have Curl to do a get on $twitter_get_url. Unfortunately I can't tell you what the error is, as the connection keeps resetting right after the error. Also, to remind you, the same Twitter url on my own machine works fine; just when I deploy it to our servers it breaks.</p> <p>Here's the strange thing. I tried ssh'ing into each of our servers and executing Curl from the command line with the same url and it worked. That proves to me that the call is not being blocked by the firewall or something.</p> <p>So what I'm trying to figure out is this: why does running Curl from the CL work, but using Curl lib to do a get on the same URL seems to break? I don't think it's a bug in the CI Curl library I'm using, as I tried using the http_response function from <a href="http://php.net/manual/en/book.curl.php" rel="nofollow">http://php.net/manual/en/book.curl.php</a> as well to test and it also seemingly threw an error.</p> <p>As for the exact error; the only clue I have to the error is that the script takes a long while to fail and resets the connection; so I'm thinking it might be a timeout. I put the following code at the top of my controller to enable error display; but still didn't get any error message:</p> <pre><code>error_reporting(E_ALL); ini_set( 'display_errors','1'); </code></pre> <p>Any constructive input is greatly appreciated.</p> <p>Thanks, Frank</p>
    singulars
    1. This table or related slice is empty.
    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.
    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