php中oauth开发包,如何使用,php需要设置什么? php中oauth开发包,如何使用,php需要设置什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 需要此文件php_oauth.dll (windows)放入/bin/php[version]/ext您需要更改 php.ini 加载 oauth (动态扩展)extension=php_oauth.dll 参考:http://php.net/oauth$req_url = 'https://fireeagle.yahooapis.com/oauth/request_token';$authurl = 'https://fireeagle.yahoo.net/oauth/authorize';$acc_url = 'https://fireeagle.yahooapis.com/oauth/access_token';$api_url = 'https://fireeagle.yahooapis.com/api/0.1';$conskey = 'your_consumer_key';$conssec = 'your_consumer_secret';session_start();// In state=1 the next request should include an oauth_token.// If it doesn't go back to 0if(!isset($_GET['oauth_token']) && $_SESSION['state']==1) $_SESSION['state'] = 0;try { $oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI); $oauth->enableDebug(); if(!isset($_GET['oauth_token']) && !$_SESSION['state']) { $request_token_info = $oauth->getRequestToken($req_url); $_SESSION['secret'] = $request_token_info['oauth_token_secret']; $_SESSION['state'] = 1; header('Location: '.$authurl.'?oauth_token='.$request_token_info['oauth_token']); exit; } else if($_SESSION['state']==1) { $oauth->setToken($_GET['oauth_token'],$_SESSION['secret']); $access_token_info = $oauth->getAccessToken($acc_url); $_SESSION['state'] = 2; $_SESSION['token'] = $access_token_info['oauth_token']; $_SESSION['secret'] = $access_token_info['oauth_token_secret']; } $oauth->setToken($_SESSION['token'],$_SESSION['secret']); $oauth->fetch("$api_url/user.json"); $json = json_decode($oauth->getLastResponse()); print_r($json);} catch(OAuthException $E) { print_r($E);}?> 需要为第三方登录按钮写一个申请request的php并将用户重定向到服务商登录页面,给服务商提供一个URL来跳转回我们的网站(php脚本:接受oauth_token等,并请求access,获取用户信息等,最终给用户呈现登录成功界面)。 关于两个开源系统集成问题(phpbb wordpress) 用PHP怎么获取这个文本的指定值 求一段滚动广告的js ~循环显示列表信息~ 如何计算任意两个日期之间有多少个月份? 有人关注phpchina.cn吗? 数组问题? 谁有做大型网站页面的动态缓冲经验,请进。相关的也可以进来讨论。 关于计数器的问题!在线等待!! 能不能用PHP在图片上写汉字?!?! 请教关于网页收藏功能的问题 新手求助 php使用其他系统接口的原理
放入/bin/php[version]/ext您需要更改 php.ini 加载 oauth (动态扩展)
extension=php_oauth.dll
$authurl = 'https://fireeagle.yahoo.net/oauth/authorize';
$acc_url = 'https://fireeagle.yahooapis.com/oauth/access_token';
$api_url = 'https://fireeagle.yahooapis.com/api/0.1';
$conskey = 'your_consumer_key';
$conssec = 'your_consumer_secret';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['state']==1) $_SESSION['state'] = 0;
try {
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
if(!isset($_GET['oauth_token']) && !$_SESSION['state']) {
$request_token_info = $oauth->getRequestToken($req_url);
$_SESSION['secret'] = $request_token_info['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: '.$authurl.'?oauth_token='.$request_token_info['oauth_token']);
exit;
} else if($_SESSION['state']==1) {
$oauth->setToken($_GET['oauth_token'],$_SESSION['secret']);
$access_token_info = $oauth->getAccessToken($acc_url);
$_SESSION['state'] = 2;
$_SESSION['token'] = $access_token_info['oauth_token'];
$_SESSION['secret'] = $access_token_info['oauth_token_secret'];
}
$oauth->setToken($_SESSION['token'],$_SESSION['secret']);
$oauth->fetch("$api_url/user.json");
$json = json_decode($oauth->getLastResponse());
print_r($json);
} catch(OAuthException $E) {
print_r($E);
}
?>