开发者

twitter account timeline in my site

I am using a curl based library but it is showing me invalid username and password each time although my username and password are correct.

I am bit confuse. Can anybody let me know clea开发者_如何学编程r step to show my twitter timeline into my site

Thanks !!!


Take a look at this page: http://apiwiki.twitter.com/Things-Every-Developer-Should-Know

The tricky part is the curl options. You can see how I used them in the example below.

The part you want from the apiwiki is the example in answer #8. Specifically:

Here's the friends timeline docs. You can get the info you want in XML, JSON, RSS, or Atom form. JSON would probably be the easiest, since you can parse that simply with PHP.

Ok, to turn this into PHP you can use this: `

<?php
// create a new cURL resource
$curl = curl_init();
// set URL and other appropriate options
$options = array(CURLOPT_URL => 'http://api.twitter.com/1/statuses/friends_timeline.json',  
                 CURLOPT_USERPWD => 'USERNAME:PASSWORD',
                 CURLOPT_RETURNTRANSFER => true
                );            

// set URL and other appropriate options
curl_setopt_array($curl, $options);
// grab URL and pass it to the browser
$json = curl_exec($curl);
// close cURL resource, and free up system resources
curl_close($curl);
$obj = json_decode($json);    
foreach($obj as $var => $value)
{
    echo "Message number: $var <br/>";    
    echo "Name: " . $obj[$var]->user->name;
    echo "Handle: " . $obj[$var]->user->screen_name . "<br/>";        
    echo "Message: " . $obj[$var]->text;        
    echo "Created" . $obj[$var]->created_at . "<br/>";                    
    echo "URL" . $obj[$var]->user->url . "<br/>";
    echo "Location" . $obj[$var]->user->location . "<br/>";       
    echo "<br/>";
}
?>`

try this bcoz already i got the problem like this.. i did succeed.

hope it helps magana

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜