Note that there are some explanatory texts on larger screens.

plurals
  1. POExceeding twitter calls even though I've only made 1/hour max
    text
    copied!<p>I've just set up a website with a new host and uploaded bits and bobs only to find that my script to get a particular users tweets had broken. I was being told that i had exceeded my limit of 150 calls to the twitter api.</p> <p>At the time this may have made sense as i was testing everything and reloading the page a lot. However I've made only a couple of attempts today but all i ever get is the same error. I even rewrote my code so that it cached all the tweets i asked for for an hour, meaning at most 1 call an hour but its still not changing. Heres the code im using to get, cache and retrieve tweets;</p> <pre><code>function getUrl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $content = curl_exec($ch); curl_close($ch); return $content; } function getContent($file, $url, $hours = 1) { //vars $CurrentTime = time(); $ExpireTime = $hours * 60 * 60; $FileTime = filemtime($file); if(file_exists($file) &amp;&amp; ($CurrentTime - $ExpireTime &lt; $FileTime)) { //echo 'returning from cached file'; return json_decode(file_get_contents($file), true); } else { $content = getUrl($url); $fh = fopen($file, 'w'); fwrite($fh, $content); fclose($fh); //echo 'retrieved fresh from '.$url.':: '.$content; return json_decode($content, true); } } $NumTweets = 3; $AccountName = "TWITTERUSERNAME"; //this can be any username $URL = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&amp;include_rts=true&amp;screen_name=".$AccountName."&amp;count=".$NumTweets; $XML = getContent('./lib/inc/tweets.txt', $URL); </code></pre> <p>I then use the following to define the tweets and time they were created, then print them out in a similar manor;</p> <pre><code> for($i = 0; $i &lt; $NumTweets; $i++) { $Tweet['text'][$i] = formatTwitString($XML[$i]['text']); $Tweet['time'][$i] = formatTwitTime($XML[$i]['created_at']); } </code></pre> <p>The format functions are irrelevant, i know they work fine.</p> <p>The thing is, if i manually enter the $URL var that gets generated in my browser, i can load the tweets without a problem, its only when loading it through the website that i get the error, i tried copying the content using this method and saving it to a file on another webserver and replacing the twitter $URL with the other servers url and that worked fine,</p> <p>so i dont think theres anything wrong with my code, but somehow my calls to twitter are getting rinsed, could this be other websites on the same host(iPage.com) using up these calls to twitter somehow? I'm a bit lost, please help, Thanks.</p>
 

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