我在 ZF2 中实现了linkedin api。
请设置回调 url,如linkedIn api 的访问权限和密钥。
$content = $linkedInObject->getProfile("~:(id,first-name,last-name,headline,picture-url)");
$profile = $this->objectToArray($content);
/*
public $base_url = "http://api.linkedin.com";
public $secure_base_url = "https://api.linkedin.com";
public $oauth_callback = "oob";
*/
function getProfile($resource = "~")
{
$profile_url = $this->base_url . "/v1/people/" . $resource;
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "GET", $profile_url);
$request->sign_request($this->signature_method, $this->consumer, $this->access_token);
$auth_header = $request->to_header("https://api.linkedin.com"); # this is the realm
$response = $this->httpRequest($profile_url, $auth_header, "GET");
return $response;
}
// 为 ZF2 修改,但在你的情况下
http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,picture-url)
现在你可以得到 $profile['first-name'] 的名字。
谢谢