Php 如何在用户配置文件中的logeed上推特消息

Php 如何在用户配置文件中的logeed上推特消息,php,posts,tweets,Php,Posts,Tweets,我已经将tweeter连接到我的网站。我使用oauth代码在tweeter上发布。 我已经提到了我在下面使用的部分代码 $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret); // Your Message $message = "hi I am fine"; // Send tweet $tweet->post('statuses/update', array('s

我已经将tweeter连接到我的网站。我使用oauth代码在tweeter上发布。 我已经提到了我在下面使用的部分代码

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

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

我已经通过JS完成了此操作。那可能对你有帮助

代码是这样的:

与TWITTER分享:

<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>

函数twitter_click()
{u=location.href;t=document.title;window.open(
'http://twitter.com/share?url=“+encodeURIComponent(u)+”&text=“+encodeURIComponent(t),“share”,
'toolbar=0,status=0,width=626,height=436');返回false;}
与FACEBOOK共享:

<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>

函数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');返回false;}

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

但最重要的是要弄清楚错误是什么以及为什么它不起作用。简单地替换

$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

我已经使用了相同的代码,第一次它不工作,因为我的应用程序是只读类型的,现在可以正常工作了!因此,请确保您的应用程序设置至少为读写类型。这里详细介绍了解决方案:

确保您已授予在用户墙上发布的权限。我可以在哪里授予在用户墙上发布的权限我是否必须更改我使用的应用程序的设置?感谢您的回复,但我需要的是,当用户查看任何帖子时,应该通过我的网站自动完成发布或者类似的东西,我不想让用户手动发布