Get Twitter feed on my site using PHP

I am just wondering what PHP methods I would use to get the latest Twitter user tweeter to display in a box on my website?

any suggestions on how I can achieve this would be great.

amuses

+3
source share
2 answers

There is also a built-in simplexml function:

// Parse the raw xml
$xml    =    simplexml_load_file('http://twitter.com/statuses/user_timeline/{yourfeed}.rss');


// Go through each tweet
foreach ($xml->channel->item as $tweet)
{
    echo $tweet->title . '<br />';
}
+3
source

Try the library: http://dev.twitter.com/pages/libraries#php

Or, if for some reason they seem redundant, load the feed via cURL and simplexml_load_string. Manipulate if necessary.

This will show your last tweet:

<?php

$ch = curl_init("http://twitter.com/statuses/user_timeline/{yourtwitterfeed}.rss");
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

$data = simplexml_load_string(curl_exec($ch));
curl_close($ch);

echo $data->channel->item[0]->title;

EDIT: Ha. simplexml_load_file ( "{url }" ) cURL. , .

+1

Source: https://habr.com/ru/post/1753666/


All Articles