本文整理汇总了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');