3
這似乎是redirect.php
沒有正確抓取訪問令牌的問題。我瀏覽過並發現很多人有這個問題,但我無法弄清楚如何解決它。這個相同的代碼在本地主機上工作,但在我的實時版本上失敗。任何想法爲什麼/如何解決它?有沒有辦法我可以手動設置這些?Twitter OAuth通過本地主機連接,實時版本失敗?
<?php
/* Start session and load library. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
/* Save temporary credentials to session. */
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
case 200:
/* Build authorize URL and redirect user to Twitter. */
$url = $connection->getAuthorizeURL($token);
header('Location: ' . $url);
break;
default:
/* Show notification if something went wrong. */
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}
你試過不同的圖書館嗎?我對EpiTwitter沒有任何問題http://www.jaisenmathai.com/articles/twitter-async-documentation.html –