J'ai une requête php oauth qui envoie une requête HTTP à yahoo, et je reçois des informations utilisateur privées qui me sont retournées. Je peux l'obtenir pour imprimer ce qui a été retourné, mais comment puis-je sélectionner une seule variable? Par exemple, je veux juste imprimer le nom de Jonathan Lucroy.Accès aux données retournées
Voici ce que je, 'utilise pour appeler:
** Heres a link to the oauth_client class for the referenced functions below **
if(strlen($client->client_id) == 0
|| strlen($client->client_secret) == 0)
die('Please go to Yahoo Apps page https://developer.apps.yahoo.com/projects/ , '.
'create a project, and in the line '.$application_line.
' set the client_id to Consumer key and client_secret with Consumer secret. '.
'The Callback URL must be '.$client->redirect_uri).' Make sure you enable the '.
'necessary permissions to execute the API calls your application needs.';
if(($success = $client->Initialize()))
{
if(($success = $client->Process()))
{
if(strlen($client->access_token))
{
$client->storeAccessToken($client->access_token);
$success = $client->CallAPI(
'http://fantasysports.yahooapis.com/fantasy/v2/team/328.l.203329.t.12/roster;week=9',
'GET', array(
'q'=>'',
'format'=>'json'
), array('FailOnAccessError'=>true), $user);
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';
}
}
$success = $client->Finalize($success);
}
if($client->exit)
exit;
if(strlen($client->authorization_error))
{
$client->error = $client->authorization_error;
$success = false;
}
if($success)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Yahoo OAuth client results</title>
</head>
<body>
<?php
echo '<h1>', HtmlSpecialChars($user->query->results->profile->nickname),
' you have logged in successfully with Yahoo!</h1>';
echo '<pre>', HtmlSpecialChars(print_r($user, 1)), '</pre>';
echo '<h6>'.$user.'</h6>';
?>
</body>
</html>
Et voici ce que je suis l'impression:
stdClass Object
(
[fantasy_content] => stdClass Object
(
[xml:lang] => en-US
[yahoo:uri] => /fantasy/v2/team/328.l.203329.t.12/roster;week=9
[team] => Array
(
[0] => Array
(
[0] => stdClass Object
(
[team_key] => 328.l.203329.t.12
)
[1] => stdClass Object
(
[team_id] => 12
)
[2] => stdClass Object
(
[name] => Kevin Matesi's Team
)
[3] => stdClass Object
(
[is_owned_by_current_login] => 1
)
[4] => stdClass Object
(
[url] => http://baseball.fantasysports.yahoo.com/b1/203329/12
)
[5] => stdClass Object
(
[team_logos] => Array
(
[0] => stdClass Object
(
[team_logo] => stdClass Object
(
[size] => large
[url] => http://l.yimg.com/dh/ap/fantasy/img/mlb/icon_1_lg.gif
)
)
)
)
[6] => Array
(
)
[7] => stdClass Object
(
[waiver_priority] => 3
)
[8] => Array
(
)
[9] => stdClass Object
(
[number_of_moves] => 0
)
[10] => stdClass Object
(
[number_of_trades] => 0
)
[11] => stdClass Object
(
[roster_adds] => stdClass Object
(
[coverage_type] => week
[coverage_value] => 7
[value] => 0
)
)
[12] => Array
(
)
[13] => stdClass Object
(
[managers] => Array
(
[0] => stdClass Object
(
[manager] => stdClass Object
(
[manager_id] => 12
[nickname] => Kmatesi
[guid] => IYEZUHTVBYRLIB3OAQC5WRZPQY
[is_current_login] => 1
)
)
)
)
)
[1] => stdClass Object
(
[roster] => stdClass Object
(
[coverage_type] => date
[date] => 2014-05-26
[is_editable] => 1
[0] => stdClass Object
(
[players] => stdClass Object
(
[0] => stdClass Object
(
[player] => Array
(
[0] => Array
(
[0] => stdClass Object
(
[player_key] => 328.p.8609
)
[1] => stdClass Object
(
[player_id] => 8609
)
[2] => stdClass Object
(
[name] => stdClass Object
(
[full] => Jonathan Lucroy
[first] => Jonathan
[last] => Lucroy
[ascii_first] => Jonathan
[ascii_last] => Lucroy
)
)
[3] => stdClass Object
(
[editorial_player_key] => mlb.p.8609
)
[4] => stdClass Object
(
[editorial_team_key] => mlb.t.8
)
[5] => stdClass Object
(
[editorial_team_full_name] => Milwaukee Brewers
)
[6] => stdClass Object
(
[editorial_team_abbr] => Mil
)
[7] => stdClass Object
(
[uniform_number] => 20
)
[8] => stdClass Object
(
[display_position] => C,1B
)
[9] => stdClass Object
(
[headshot] => stdClass Object
(
[url] => http://l.yimg.com/iu/api/res/1.2/LDlsOwlp8kcebcX0hWqbnw--/YXBwaWQ9eXZpZGVvO2NoPTg2MDtjcj0xO2N3PTY1OTtkeD0xO2R5PTE7Zmk9dWxjcm9wO2g9NjA7cT0xMDA7dz00Ng--/http://l.yimg.com/j/assets/i/us/sp/v/mlb/players_l/20130405/8609.1.jpg
[size] => small
)
[image_url] => http://l.yimg.com/iu/api/res/1.2/LDlsOwlp8kcebcX0hWqbnw--/YXBwaWQ9eXZpZGVvO2NoPTg2MDtjcj0xO2N3PTY1OTtkeD0xO2R5PTE7Zmk9dWxjcm9wO2g9NjA7cT0xMDA7dz00Ng--/http://l.yimg.com/j/assets/i/us/sp/v/mlb/players_l/20130405/8609.1.jpg
)
[10] => stdClass Object
(
[is_undroppable] => 0
)
[11] => stdClass Object
(
[position_type] => B
)
[12] => stdClass Object
(
[eligible_positions] => Array
(
[0] => stdClass Object
(
[position] => C
)
[1] => stdClass Object
(
[position] => 1B
)
[2] => stdClass Object
(
[position] => Util
)
)
)
[13] => stdClass Object
(
[has_player_notes] => 1
)
[14] => stdClass Object
(
[has_recent_player_notes] => 1
)
)
[1] => stdClass Object
2 astuces: objet ->, tableau [], par exemple $ variable-> fantasy_content-> team [1] ... – sunshinejr
Je reçois toujours cette erreur: "L'objet de la classe stdClass n'a pas pu être converti en chaîne" –