gpt4 book ai didi

php - 为什么 Yahoo Social SDK for PHP 的示例代码总是为 session 变量返回 NULL?

转载 作者:可可西里 更新时间:2023-11-01 13:30:50 24 4
gpt4 key购买 nike

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_KEYCONSUMER_SECRETAPPID但是 $session 变量 始终为 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 !!我认为这是问题的根源。我按原样使用示例代码。所以,我不确定为什么会这样。

有什么想法吗??我缺少什么?

最佳答案

试试这个:

$yahooUserData = YahooSession::requireSession($yahooConsumerKey, $yahooConsumerSecret, $yahooAppId, $returnUrl);

if (!empty($yahooUserData)) {
$yahooUserId = $yahooUserData->guid;
$accessToken = $yahooUserData->accessToken->key;
}

关于php - 为什么 Yahoo Social SDK for PHP 的示例代码总是为 session 变量返回 NULL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12950575/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com