1
我已經創建了一個Twitter應用程序,我用它來發布推文。我無法解決的問題是每次必須允許訪問我的應用程序。PHP OAuth Twitter
因此可以說我需要推送三條消息,所以所有三次我必須允許訪問我的應用程序。
我只是需要一旦用戶允許訪問我的應用程序,下次他應該只被要求允許訪問是當他/她重新登錄時。
這裏是我的代碼,我使用
Share content on twitter"; include 'lib/EpiCurl.php'; include 'lib/EpiOAuth.php'; include 'lib/EpiTwitter.php'; include 'lib/secret.php'; $twitterObj = new EpiTwitter($consumer_key, $consumer_secret); $oauth_token = $_GET['oauth_token']; if($oauth_token == '') { $url = $twitterObj->getAuthorizationUrl(); echo ""; echo "Sign In with Twitter"; echo ""; } else { $twitterObj->setToken($_GET['oauth_token']); $token = $twitterObj->getAccessToken(); $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret); $_SESSION['ot'] = $token->oauth_token; $_SESSION['ots'] = $token->oauth_token_secret; $twitterInfo= $twitterObj->get_accountVerify_credentials(); $twitterInfo->response; $username = $twitterInfo->screen_name; $profilepic = $twitterInfo->profile_image_url; include 'update.php'; } if(isset($_POST['submit'])) { $msg = $_REQUEST['tweet']; $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']); $update_status = $twitterObj->post_statusesUpdate(array('status' => $msg)); $temp = $update_status->response; header("Location: MessageStatus.html"); exit(); } ?>