本文整理汇总了PHP中Abraham\TwitterOAuth\TwitterOAuth::getAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::getAccessToken方法的具体用法?PHP TwitterOAuth::getAccessToken怎么用?PHP TwitterOAuth::getAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Abraham\TwitterOAuth\TwitterOAuth
的用法示例。
在下文中一共展示了TwitterOAuth::getAccessToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: twitterCallback
public function twitterCallback()
{
//echo "helloCallback";
if (!empty($_GET['oauth_verifier']) && !empty($this->request->session()->read('oauth_token')) && !empty($this->request->session()->read('oauth_token_secret'))) {
$connection = new TwitterOAuth($this->consumerKey, $this->consumerSecret, $this->request->session()->read('oauth_token'), $this->request->session()->read('oauth_token_secret'));
$access_tokencredential = $connection->getAccessToken($_REQUEST['oauth_verifier'], $this->request->session()->read('oauth_token'));
$uniqueOauthToken = $access_tokencredential['oauth_token'];
$uniqueOauthTokenSecret = $access_tokencredential['oauth_token_secret'];
$twitteroauth = new TwitterOAuth($this->consumerKey, $this->consumerSecret, $uniqueOauthToken, $uniqueOauthTokenSecret);
$message = "Tweet From Panovus Team!";
//$output = $twitteroauth->get('friends/list');
//$output = $twitteroauth->post("statuses/update", array("status" => $message));
//echo"<pre style='color:red'>";
//print_r($output);
//echo'</pre>';
/*
echo"<pre style='color:red'>";
print_r($access_tokencredential);
echo "</pre>";
*/
//return $output;
$id = $this->Auth->user('partner_id');
$partner = $this->Partners->get($id);
$data = ["twitter_oauth_token" => $uniqueOauthToken, "twitter_oauth_token_secret" => $uniqueOauthTokenSecret];
$partner = $this->Partners->patchEntity($partner, $data);
//echo "<pre style='color:red'>";
//print_r($partner);
//echo "</pre>";
if ($this->Partners->save($partner)) {
$this->Flash->success('Token has been saved.');
return $this->redirect(['controller' => 'PartnerCampaignEmailSettings']);
} else {
$this->Flash->error('The partner could not be saved. Please try again. If you continue to experience problems, please contact Customer Support.');
}
} else {
//end if get
$this->Flash->error('Authorization has failed!');
return $this->redirect(['controller' => 'PartnerCampaignEmailSettings']);
}
}
示例2: test
function test()
{
if (!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])) {
// We've got everything we need
// TwitterOAuth instance, with two new parameters we got in twitter_login.php
$twitteroauth = new TwitterOAuth('YOUR_CONSUMER_KEY', 'YOUR_CONSUMER_SECRET', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
// Let's request the access token
$access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']);
// Save it in a session var
$_SESSION['access_token'] = $access_token;
// Let's get the user's info
$user_info = $twitteroauth->get('account/verify_credentials');
// Print user's info
print_r($user_info);
} else {
// Something's missing, go back to square 1
redirect("client/");
echo "missing";
die;
//header('Location: twitter_login.php');
}
}