我正在使用rest api从php获取来自linkedin的基本配置文件数据。我成功地能够生成访问代码和访问令牌,但每当我尝试使用以下url获取基本配置文件时,我都会遇到ssl必需的错误 https://api.linkedin.com/v1/people/~?format=json
我按照所有步骤制作了https://developer.linkedin.com/docs/oauth2
中列出的经过身份验证的请求我使用非ssl url作为回调参数,是否有必要使用ssl url?如果没有,那么为什么我会收到此错误。 寻找解决方案
下面是获取个人资料字段的代码
$host = "api.linkedin.com";
$path = "/v1/people/~)";
//$arr = array('oauth2_access_token' => $access['access_token']);
$token = $access['access_token'];
$header[] = "Authorization: Bearer ".$token;
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$ch = curl_init();
// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);
// set request as regular post
//curl_setopt($ch, CURLOPT_HTTPGET, true);
// set http version
curl_setopt($ch, CURLOPT_HTTP_VERSION, 'HTTP/1.1');
// set data to be send
//curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));
// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
// set header
curl_setopt($ch, CURLOPT_CERTINFO, true);
// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
var_export($response);
答案 0 :(得分:4)
我的解决方案是使用https://而不仅仅是http://