0
因此,進出口使用Twitter的亞伯拉罕庫這樣的:使用Twitter API(亞伯拉罕lirbary)
Connect.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.';
}
和index.php文件:
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$userInfo = $connection->get('account/verify_credentials');
但我不斷收到錯誤:
「無法驗證你」
我在做什麼錯?
的可能重複[ 「無法驗證您的身份。」 - 使用Twitter OAuth時發生錯誤](http://stackoverflow.com/questions/2657452/could-not-authenticate-you-error-when-using-twitter-oauth) – ajreal
IT不重複。我已經應用了寫在該線程中的解決方案:S –