我成功地从linkedIn API 收集用户信息。当我想获得语言水平时,我的问题就出现了。它在文档(https://developer.linkedin.com/documents/profile-fields#languages)中表示语言对象具有熟练度成员,但我在响应中看不到它。我的错误可能是什么?下面是来自 api 的语言对象的结构:
var_dump($user->languages->values[0]);
输出:
object(stdClass)#10 (2)
{
["id"]=> int(10)
["language"]=> object(stdClass)#11 (1)
{
["name"]=> string(8) "Türkçe"
}
}
这是我进行的 api 调用
$user = fetch('GET', '/v1/people/~:(firstName,lastName,positions,skills,languages,educations)');
function fetch($method, $resource, $body = '') {
$params = array('oauth2_access_token' => $_SESSION['access_token'],
'format' => 'json',
);
$url = 'https://api.linkedin.com' . $resource . '?' . http_build_query($params);
$context = stream_context_create(
array('http' =>
array('method' => $method,
)
)
);
$response = file_get_contents($url, false, $context);
$user = json_decode($response);
return $user;
}