本文整理匯總了PHP中Twitter::oAuthAuthorize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::oAuthAuthorize方法的具體用法?PHP Twitter::oAuthAuthorize怎麽用?PHP Twitter::oAuthAuthorize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::oAuthAuthorize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Twitter
function auth_set($member_id, $oauth_url)
{
require_lang('twitter');
require_code('twitter');
$api_key = get_option('twitter_api_key', true);
$api_secret = get_option('twitter_api_secret', true);
$twitter = new Twitter($api_key, $api_secret);
if (get_param_integer('oauth_in_progress', 0) == 0) {
$response = $twitter->oAuthRequestToken($oauth_url->evaluate());
$twitter->oAuthAuthorize($response['oauth_token']);
exit;
}
$response = $twitter->oAuthAccessToken(get_param('oauth_token'), get_param('oauth_verifier'));
if (!isset($response['oauth_token'])) {
attach_message(do_lang_tempcode('TWITTER_OAUTH_FAIL', escape_html($response['message'])), 'warn');
return false;
}
$save_to = 'twitter_oauth_token';
if (!is_null($member_id)) {
$save_to .= '__' . strval($member_id);
}
set_long_value($save_to, $response['oauth_token']);
$save_to = 'twitter_oauth_token_secret';
if (!is_null($member_id)) {
$save_to .= '__' . strval($member_id);
}
set_long_value($save_to, $response['oauth_token_secret']);
return true;
}
示例2: showPass
function execute($par)
{
global $wgRequest, $wgOut, $wgUser, $wgServer, $IP;
// this only for staff
if (!in_array('staff', $wgUser->getGroups())) {
$wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
return;
}
$target = isset($par) ? $par : $wgRequest->getVal('target');
// set up a new account if we have been given one
if ($wgRequest->wasPosted()) {
$cat = Title::makeTitle(NS_CATEGORY, $wgRequest->getVal('category'));
// set up the link between the twitter account and the category
$username = $wgRequest->getVal('username');
$password = $wgRequest->getVal('password');
$dbw = wfGetDB(DB_MASTER);
$opts = array('tfc_username' => $username, 'tfc_category' => $cat->getDBKey());
$count = $dbw->selectField('twitterfeedcatgories', 'count(*)', $opts);
if ($count == 0) {
// there can only be 1 pair like this
$dbw->insert('twitterfeedcatgories', $opts);
}
// do we already have auth tokens set up for this twitter account?
$row = $dbw->selectRow('twitterfeedaccounts', array('*'), array('tws_username' => $username));
if (!$row->tws_token) {
// insert what we know, create the initial account
if (!$row) {
$dbw->insert('twitterfeedaccounts', array('tws_username' => $username, 'tws_password' => $password));
}
// then send them on their way to authenticate their tokens, they'll be back, don't worry
$callback = $wgServer . '/Special:TwitterAccounts/' . urlencode($username);
require_once "{$IP}/extensions/wikihow/common/twitterapi.php";
$twitter = new Twitter(WH_TWITTER_CONSUMER_KEY, WH_TWITTER_CONSUMER_SEC);
$twitter->oAuthRequestToken($callback);
$twitter->oAuthAuthorize();
return;
}
}
// process the call back and update the appropriate tokens
if ($target && $wgRequest->getVal('oauth_token')) {
require_once "{$IP}/extensions/wikihow/common/twitterapi.php";
$twitter = new Twitter(WH_TWITTER_CONSUMER_KEY, WH_TWITTER_CONSUMER_SEC);
$twitter->oAuthRequestToken($callback);
$response = $twitter->oAuthAccessToken($_GET['oauth_token'], $_GET['oauth_verifier']);
$dbw = wfGetDB(DB_MASTER);
$dbw->update('twitterfeedaccounts', array('tws_token' => $response['oauth_token'], 'tws_verifier' => $wgRequest->getVal('oauth_verifier'), 'tws_secret' => $response['oauth_token_secret']), array('tws_username' => $target));
$wgOut->addHTML("<b>Tokens updated for {$target}</b><br/><br/>");
}
// delete any relationships that were requeted
if ($wgRequest->getVal('eaction') == 'del') {
$username = $wgRequest->getVal('username');
$cat = Title::makeTitle(NS_CATEGORY, $wgRequest->getVal('category'));
$dbw = wfGetDB(DB_MASTER);
$opts = array('tfc_username' => $username, 'tfc_category' => $cat->getDBKey());
$dbw->delete('twitterfeedcatgories', $opts);
$wgOut->addHTML("<b>New articles will no longer be tweeted to {$username} for the category {$cat->getText()}</b><br/><br/>");
}
// show all of the active accounts
$dbr = wfGetDB(DB_MASTER);
$res = $dbr->select(array('twitterfeedaccounts', 'twitterfeedcatgories'), array('*'), array('tfc_username=tws_username'));
$wgOut->addHTML(<<<EOSCRIPT
function showPass(id, pass) {
\t\$('#pass_' + id).html(pass);\t
\treturn false;
}
function showCats() {
\tvar url = '/Special:Categoryhelper?type=categorypopup';
var modalParams = {
width: 650,
height: 500,
title: "Select a category",
modal: true,
position: 'center'
\t\tcloseText: 'Close',
};
\t\$('#dialog-box').load(url, function() {
\t\t\t\$("#dialog-box").dialog(modalParams);
\t\t}
\t);
\treturn false;
}
\t\t
function twtDelete(cat, user) {
\tif (confirm("Are you sure you no longer want to tweet to the twitter account " + user + " for the category " + cat + "?")) {
\t\twindow.location.href='/Special:TwitterAccounts?eaction=del&username=' + encodeURIComponent(user) + "&category=" + encodeURIComponent(cat);
\t}
}
EOSCRIPT
);
$wgOut->addHTML("<table style='margin-left: auto; margin-right: auto;' width='70%'>\n\t\t\t\t<tr><td>Username</td><td>Password</td><td>Category</td><td style='text-align:right;'>Delete</td></tr>");
$index = 0;
while ($row = $dbr->fetchObject($res)) {
$cat = Title::makeTitle(NS_CATEGORY, $row->tfc_category);
$wgOut->addHTML("<tr><td><a href='http://twitter.com/{$row->tws_username}' target='new'>{$row->tws_username}</a></td>");
$wgOut->addHTML("<td><span id='pass_{$index}'>******* \n\t\t\t\t\t<a href='#' onclick='return showPass({$index}, \"{$row->tws_password}\");'>Show</a></span></td>");
$wgOut->addHTML("<td><a href='{$cat->getFullURL()}' target='new'>{$cat->getText()}</td>");
$wgOut->addHTML("<td style='text-align:right;'><a href='#' onclick='twtDelete(\"{$cat->getText()}\", \"{$row->tws_username}\");'>x</td></tr>");
$index++;
}
//.........這裏部分代碼省略.........
示例3: getLogin
public function getLogin()
{
if (Auth::check()) {
return Redirect::to('/')->with('message', 'ログイン済みです。');
}
$tokens = Twitter::oAuthRequestToken();
//var_dump($tokens);exit;
Twitter::oAuthAuthorize($tokens['oauth_token']);
exit;
}
示例4: Twitter
require_once 'twitter.php';
/*
APPLICATION LEVEL DETAILS
Create new Twitter class instance with our 'consumer key' and 'consumer secret'
Find this on your Twitter app page. Example: http://screencast.com/t/a5s93L91V
*/
$twitter = new Twitter('2jSDrs6wyzxVyPKn4ex3LQ', 'vVXyzrcwPFDAQ8fxrgjgfkZ274QejvadOHKUp3MyNS0');
# !!
/*-------------------------------------------------------------------------------------------------
GET TOKEN / SECRET
-------------------------------------------------------------------------------------------------*/
// get a request token
$twitter->oAuthRequestToken('http://susanbuck.net/classes/inclass/exercises/twitter/authorize.php');
# !!
// authorize
if (!isset($_GET['oauth_token'])) {
$twitter->oAuthAuthorize();
}
// get tokens
$response = $twitter->oAuthAccessToken($_GET['oauth_token'], $_GET['oauth_verifier']);
print_r($response);
?>
<title>Twitter API Authorize</title>
<br/><br/>
<a href='/classes/viewSource/?path=<?php
echo $_SERVER['PHP_SELF'];
?>
' target='_blank'>View Source</a><br/><br/><br/>
<a href='http://classes.verkoyen.eu/modules/twitter_oauth/files/php_twitter_2_0_3.zip'>Download twitter.php (wrapper library)</a><br/><br/>