1

我已将高音扬声器与我的网站连接。我已使用 oauth 代码在高音扬声器上发布。我已经提到了我在下面使用的部分代码。

$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
// Your Message
$message = "hi I am fine";
// Send tweet     
$tweet->post('statuses/update', array('status' => "$message"));

但是我不能在登录的用户页面上发布,它只显示在应用程序的用户页面上,我应该用这个代码添加任何东西吗?如果是这样,请让我知道我应该如何处理代码。

4

2 回答 2

2

我已经通过 JS 做到了这一点。这可能对你有帮助。

代码是这样的:

与推特分享:

<script type="text/javascript">
function twitter_click()
{u=location.href;t=document.title;window.open(
'http://twitter.com/share?url='+encodeURIComponent(u)+'&text='+encodeURIComponent(t),'sharer',
'toolbar=0,status=0,width=626,height=436');return false;}</script>

 <a href="javascript:void(0);" onclick="return twitter_click()">
<img alt="twittershare" src="http://lh6.ggpht.com/_iEnxos6ddpE/Tb6BVrptRVI/AAAAAAAACaU/XQ0dT77GozI/tweetsip.gif"/></a>

与脸书分享:

<script type="text/javascript">
function fbs_click()
{u=location.href;t=document.title;window.open(
'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer',
'toolbar=0,status=0,width=626,height=436');return false;}</script>
<a href="javascript:void(0);" onclick="return fbs_click()">
<img alt="facebook share" src="http://lh5.ggpht.com/_iEnxos6ddpE/Tb6BUD0OGfI/AAAAAAAACaQ/0pd1LCCkPDs/SukaFB.gif"/></a>
于 2011-07-12T09:32:38.377 回答
1

这段代码没问题。它会起作用的。

但主要是弄清楚错误是什么以及为什么它不起作用。只需更换

$tweet->post('statuses/update', array('status' => "$message"));

使用:

$mytweet=$tweet->post('statuses/update', array('status' => "$message"));
var_dump($mytweet); 
// print the output coming from the post request, that you done using twitterOauth

我已经使用了相同的代码,第一次它不起作用,因为我的应用程序是只读类型,现在可以正常工作!因此,请确保您的应用程序设置至少是读取和写入类型。这里有详细的解决方案:https ://stackoverflow.com/questions/18035906/tweeting-with-php-not-working/18036339#18036339

于 2013-08-04T01:13:01.427 回答