2010-11-12 5 views
2

Je suis en train de mettre en œuvre un code Twitter qui pourrait me faire le post récent de mon compte, .Trying ce que je reçois un message d'erreur indiquantPhp 5 Twitter plug-in

"Cette méthode nécessite GET./Statuts/friends_timeline .xml? count = 5 " je suis nouveau à PHP Curl aussi j'ai essayé de chercher cette même erreur pour obtenir des indices, mais n'a pas pu obtenir de réponse satisfaisante. J'ai implémenté le code suivant.

**

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Papermashup.com | Twitter API</title> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
<style> 

.twitter_followers{ 
float:left; 
margin-right:20px; 
margin-bottom:0px; 
} 

body{ 
font-family:Verdana, Geneva, sans-serif; 
font-size:14px;} 

.user{ 
background-color:#efefef; 
margin-bottom:10px; 
border-bottom:; 
padding:10px;} 

.name{ 
font-size:14px; 
font-weight:700; 
} 

</style> 

</head> 

<body> 


<div id="header"><a href="http://www.papermashup.com/"><img src="images/logo.png" width="348" height="63" border="0" /></a></div> 
<div id="container"> 


<?php 


$login = "username:password"; 

$tweets = "http://twitter.com/statuses/friends_timeline.xml?count=5"; 
$proxy = "192.168.1.51:8080"; 
$tw = curl_init($tweets); 
//curl_setopt ($tw, CURLOPT_PROXY, $proxy); 
//curl_setopt($tw, CURLOPT_URL, $tweets); 
curl_setopt($tw, CURLOPT_USERPWD, $login); 
curl_setopt($tw, CURLOPT_POSTFIELDS, ''); 
curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE); 
$twi = curl_exec($tw); 
echo $twi;exit; 
$tweeters = new SimpleXMLElement($twi); 
$latesttweets = count($tweeters); 

if ($latesttweets>2) { 

echo "<h3>".$latesttweets." latest tweets from the users I follow | <a href=\"http://www.twitter.com/ashleyford\">Follow Me!</a></h3>"; 

} 

//echo the data 

foreach ($tweeters->status as $twit1) { 


//This finds any links in $description 
$description = $twit1->text; 

$description = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $description); 
$description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $description); 
$description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $description); 

echo "<div class='user'><a href=\"http://www.twitter.com/", $twit1->user->screen_name,"\" target=\"_blank\"><img border=\"0\" class=\"twitter_followers\" src=\"", $twit1->user->profile_image_url, "\" title=\"", $twit1->name, "\" /></a>\n"; 
echo "<div class='name'>", $twit1->user->name,"</div>"; 
echo "<div class='followers'>", $twit1->user->location,"</div>"; 
echo "<div class='location'>", $twit1->user->url,"</div>"; 
echo "<div class='text'>".$description." <div class='description'>From ", $twit1->source,"</div></div></div>";} 

curl_close($tw); 


?> 
</div> 
<div id="footer"><a href="http://www.papermashup.com">papermashup.com</a> | <a href="http://papermashup.com/using-the-twitter-api/">Back to tutorial</a></div> 
<script type="text/javascript"> 
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); 
</script> 
<script type="text/javascript"> 
try { 
var pageTracker = _gat._getTracker("UA-7025232-1"); 
pageTracker._trackPageview(); 
} catch(err) {}</script> 

</body> 
</html> 

**

Répondre

2

C'est pas à jour. Utilisez une version mise à jour d'un autre plugin Twitter. Cette façon de se connecter à Twitter est bloquée par Twitter.

+2

@Tout le monde: http: //dev.twitter.com/pages/oauth_faq – ajreal

+0

Merci ajreal, j'ai oublié le nom de l'api ... – dododedodonl