-1
我在我的網站中使用了yahoo oauth。在以下我在github上找到的代碼中,例如$user -> query -> results -> profile -> givenName
返回登錄用戶的名字,$user -> query -> results -> profile -> familyName
等等。 我搜索了很多,但我仍然不知道如何獲取用戶的電子郵件地址。如何使用PHP中的oauth登錄用戶的電子郵件
這是我的代碼:
require('include/http.php');
require('include/oauth_client.php');
$client = new oauth_client_class;
$client->debug = false;
$client->debug_http = true;
$client->server = 'Yahoo';
$client->redirect_uri = 'http://www.example.com';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if(($success = $client->Initialize()))
{
if(($success = $client->Process()))
{
if(strlen($client->access_token))
{
$success = $client->CallAPI(
'https://query.yahooapis.com/v1/yql',
'GET', array(
'q'=>'select * from social.profile where guid=me',
'format'=>'json'
), array('FailOnAccessError'=>true), $user);
}
}
$success = $client->Finalize($success);
}
if($client->exit)
exit;
if(strlen($client->authorization_error))
{
$client->error = $client->authorization_error;
$success = false;
}
if($success)
{
$yahname =$user->query->results->profile->givenName.$user->query->results->profile->familyName;
echo '<pre>', HtmlSpecialChars(print_r($user, 1)), '</pre>';
}
else
{
echo HtmlSpecialChars($client->error);
}
請讓我知道如果我做錯什麼。
歡迎使用stackoverflow。請,你能提供一些你的具體問題的代碼嗎?這可以證明你嘗試了多遠,它會幫助其他成員更好地理解你的問題,當時,你會給他們一個你的問題的背景。請檢查以下鏈接:https://stackoverflow.com/help/mcve和https://stackoverflow.com/help/how-to-ask –