Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Codeigniter twitter loops
    primarykey
    data
    text
    <p>new here!!</p> <p>Im trying to get tweets to display on a site(framework is codeigniter). I am using the twitter api (for example: <a href="https://api.twitter.com/1/statuses/user_timeline/ddarrko.xml" rel="nofollow">https://api.twitter.com/1/statuses/user_timeline/ddarrko.xml</a>) to get the tweets and subsequently insert them into a database which I will then get to display on the site. The actual code runs fine the issue is it only ever processes one tweet. my code is -</p> <p>//get twitter address</p> <pre><code> $this-&gt;load-&gt;model('admin_model'); $getadd = $this-&gt;admin_model-&gt;get_settings("twitter_address"); $twitter_user = $getadd-&gt;item_value; //define twitter xml file $xmlpath = "https://api.twitter.com/1/statuses/user_timeline/".$twitter_user.".xml"; $xml = simplexml_load_file($xmlpath); foreach ($xml-&gt;status as $tweet); { echo "&lt;pre&gt;";print_r($xml);echo "&lt;/pre&gt;"; $this-&gt;data-&gt;username=$twitter_user; $this-&gt;data-&gt;twitter_status=$tweet-&gt;text; $this-&gt;data-&gt;pub_date=$tweet-&gt;created_at; //load model and insert tweets; $this-&gt;load-&gt;model('tweet_model'); $this-&gt;tweet_model-&gt;insert_tweets($this-&gt;data); } </code></pre> <p>as you can see I am defining to run each status in xml file. The echo pre line is me testing because when printing $tweet only one tweet is coming up however even if i loop through just $xml still only one tweet is processed despite there being loads in the file.</p> <p>any help/advice would be greatly appreciated!</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.
    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