I am trying to get the sample code from the Yahoo Social SDK for PHP page to work, With no luck.
这是网站的代码段:
<?php
require("Yahoo.inc");
// Your Consumer Key (API Key) goes here.
define('CONSUMER_KEY', "");
// Your Consumer Secret goes here.
define('CONSUMER_SECRET', "");
// Your application ID goes here.
define('APPID', "");
$session = YahooSession::requireSession(CONSUMER_KEY,CONSUMER_SECRET,APPID);
?>
我设置了CONSUMER_KEY
,CONSUMER_SECRET
和APPID
。 但$session variable
始终为NULL。
在挖掘yahoo.inc源代码后,我将问题追溯到这个函数:
function getRequestToken($consumerKey, $consumerSecret, $callback);
特别是在函数中的这个调用:
$response = $client->post($request_url, "application/x-www-form-urlencoded", $parameters); $request_url: https://api.login.yahoo.com/oauth/v2/get_request_token $parameters: has my callback url
$response
变量是null
!!我认为这是问题的根源。
我按原样使用示例代码。所以,我不确定为什么会这样。
任何想法?我缺少什么?
答案 0 :(得分:1)
试试这个:
$yahooUserData = YahooSession::requireSession($yahooConsumerKey, $yahooConsumerSecret, $yahooAppId, $returnUrl);
if (!empty($yahooUserData)) {
$yahooUserId = $yahooUserData->guid;
$accessToken = $yahooUserData->accessToken->key;
}
答案 1 :(得分:0)
指定返回网址并尝试此操作...
$yahooUserData = YahooSession::requireSession($yahooConsumerKey, $yahooConsumerSecret, $yahooAppId, $returnUrl);
if (!empty($yahooUserData)) {
$yahooUserId = $yahooUserData->guid;
$accessToken = $yahooUserData->accessToken->key;
}