我看this video了解如何使用PHP向Twitter帐户发布推文。我抓住了PHP he give in the video description&添加我的应用程序&访问脚本中的令牌详细信息。
这是my code。
<?php
$the_tweet = 'hello';
// TWITTER API ==================
$consumerKey = 'qu...xF';
$consumerSecret = 'it...hG';
$oAuthToken = '24...ub';
$oAuthSecret = 'oy...d2';
include "OAuth.php";
include "twitteroauth.php";
$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
if (isset($the_tweet)) {
$tweetmsg = $the_tweet;
$tweet->post('statuses/update',array('status' => $tweetmsg));
echo "Your message has been sent to Twitter.";
} else {
echo "Your message has not been sent to Twitter.";
}
// END TWITTER API ==================
?>
此脚本的github repo是here('twitteroauth'文件夹内的'OAuth.php'和'twitteroauth.php'文件)。
我的问题
当我使用localhost(使用MAMP)运行我的代码时,推文已成功发送到我的Twitter帐户。
但是,当我把它放在我的网络托管帐户并运行代码时,推文没有发送到我的Twitter帐户,即使我仍然得到如下的成功消息。
如何解决这个问题?为什么不发送推文并且只在本地主机模式下成功发送?
这是我的应用程序&amp;令牌访问详细信息(与我的代码相同):