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).
Since you are using Browser-Based Authentication, then you will need to make sure that you are registering your application as such. You need to get your application id and secret from https://developer.apps.yahoo.com/wsregapp/. This is different from where you would create a OAuth project. BBAuth has ONLY application id and secret.
In your case, it seems like the problem is that you have an invalid application id. Considering the other answer and discussion, it looks like that you have created a OAuth project instead of a Browser-Based Authentication Project.
Regarding your question "Should I replace 'some_aplication_data' whit something else?". According to the documentation, you would probably like to replace 'some_aplication_data' with session_id().
EDIT
I have tested your code with the the above recommendations, and it is working properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With