首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Php 5 Twitter插件

Php 5 Twitter插件
EN

Stack Overflow用户
提问于 2010-11-12 11:43:08
回答 1查看 414关注 0票数 2

我正在尝试实现一个Twitter代码,它可以让我获得我的帐户的最近的帖子,.Trying -我收到错误消息,声明

“这个方法需要一个GET. /statuses/friends_timeline.xml?count=5”我对php是新手,我也试图搜索同样的错误来获得任何线索,但是无法得到满意的答案。我已经实现了以下代码。

**

代码语言:javascript
复制
<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>

**

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-11-12 20:21:08

这已经过时了。使用另一个twitter插件的更新版本。这种登录twitter的方式被twitter屏蔽了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4164223

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档