3

I'm trying to load yahoo users' emails (but I'm stuck on the auth step):

define("APPID", 'dj***NQ--');
define("SECRET", '3***7');

// Include the proper class file
$v = phpversion();

if ($v[0] == '4') {
    include("includes/yahoo/ybrowserauth.class.php4");
} elseif ($v[0] == '5') {
    include("includes/yahoo/ybrowserauth.class.php5");

} else {
    die('Error: could not find the bbauth PHP class file.');
}
$authObj = new YBBauthREST(APPID, SECRET);
//echo APPID;
// If Yahoo! isn't sending the token, then we aren't coming back from an
// authentication attempt
if (empty($_GET["token"])) {
    // You can send some data along with the authentication request
    // In this case, the data is the string 'some_application_data'
    echo 'You have not signed on using BBauth yet<br /><br />';
    echo '<a href="'.$authObj->getAuthURL('some_application_data', true).'">Click here to authorize</a>';
    return;
}

But I get this error in the yahoo landing page:

Invalid (missing) src or appid

So I'm guessing here is the problem?

echo '<a href="'.$authObj->getAuthURL('some_application_data', true).'">Click here to authorize</a>';

Should I replace 'some_aplication_data' with something else?

Edit:

I've also tried:

$callback = YahooUtil::current_url()."?in_popup";  
$auth_url = YahooSession::createAuthorizationUrl(APPID, SECRET, $callback);
echo '<a href="'.$auth_url.'">Click here to authorize</a>';

But it won't create the link or show errors (script dies).

4

2 回答 2

1

由于您使用的是基于浏览器的身份验证,因此您需要确保您正在注册您的应用程序。您需要从https://developer.apps.yahoo.com/wsregapp/获取您的应用程序 ID 和密码。这与创建 OAuth 项目的位置不同。BBAuth 只有应用程序 ID 和密码。

在您的情况下,问题似乎在于您的应用程序 ID 无效。考虑到其他答案和讨论,您似乎创建了一个 OAuth 项目而不是基于浏览器的身份验证项目。

关于您的问题“我应该用其他东西替换'some_aplication_data'吗?”。根据文档,您可能想用 session_id() 替换“some_aplication_data”。

编辑

我已经使用上述建议测试了您的代码,并且它工作正常。

于 2013-01-13T00:19:59.197 回答
0

You can generate the auth URL in this way

$callback = YahooUtil::current_url()."?in_popup";  
$auth_url = YahooSession::createAuthorizationUrl(CONSUMER_KEY, CONSUMER_SECRET, $callback);  

REFERENCE http://developer.yahoo.com/oauth/guide/oauth-userauth.html

于 2013-01-06T15:10:29.783 回答