2017-05-14 4 views
-1

내 웹 사이트에서 yahoo oauth를 사용했습니다. 예를 들어, $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); 
} 

내가 잘못 아무것도하고 있으면 알려 주시기 바랍니다 :

내 코드입니다.

+0

Welcome to stackoverflow. 제발, 당신의 특정 문제에 대한 코드를 제공 할 수 있습니까? 그것은 얼마나 멀리 시도 했는가를 증명하고 다른 회원들이 귀하의 문제를 더 잘 이해할 수 있도록 도울 것입니다. 당시에는 문제의 맥락을 알려줄 것입니다. 다음 링크를 확인하십시오. https://stackoverflow.com/help/mcve 및 https://stackoverflow.com/help/how-to-ask –

답변