本文整理匯總了PHP中OAuth::setCallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP OAuth::setCallback方法的具體用法?PHP OAuth::setCallback怎麽用?PHP OAuth::setCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OAuth
的用法示例。
在下文中一共展示了OAuth::setCallback方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: OAuth
include_once '../OAuth.php';
define('CONSUMER_KEY', '');
define('CONSUMER_SECRET', '');
define('URL_REQUEST_TOKEN', 'https://fireeagle.yahooapis.com/oauth/request_token');
define('URL_ACCESS_TOKEN', 'https://fireeagle.yahooapis.com/oauth/access_token');
define('URL_AUTHORIZE', 'https://fireeagle.yahoo.net/oauth/authorize');
define('URL_API', 'https://fireeagle.yahooapis.com/api/0.1');
session_start();
// In state=1 the next request should include an oauth_token.
// If it doesn't go back to 0
if (!isset($_GET['oauth_token']) && $_SESSION['fireeagle_state'] == 1) {
$_SESSION['fireeagle_state'] = 0;
}
try {
$oauth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET);
$oauth->setCallback('http://localhost/oauth/example/FireEagle.php');
if (!isset($_GET['oauth_token']) && !$_SESSION['fireeagle_state']) {
$requestToken = $oauth->getRequestToken(URL_REQUEST_TOKEN);
$_SESSION['fireeagle_secret'] = $requestToken['oauth_token_secret'];
$_SESSION['fireeagle_state'] = 1;
header('Location: ' . URL_AUTHORIZE . '?oauth_token=' . $requestToken['oauth_token']);
exit;
} elseif ($_SESSION['fireeagle_state'] == 1) {
$oauth->setToken($_GET['oauth_token'], $_SESSION['fireeagle_secret']);
$accessToken = $oauth->getAccessToken(URL_ACCESS_TOKEN . '?oauth_verifier=' . $_GET['oauth_verifier']);
$_SESSION['fireeagle_state'] = 2;
$_SESSION['fireeagle_token'] = $accessToken['oauth_token'];
$_SESSION['fireeagle_secret'] = $accessToken['oauth_token_secret'];
}
$oauth->setToken($_SESSION['fireeagle_token'], $_SESSION['fireeagle_secret']);
$response = $oauth->fetch(URL_API . '/user');