在访问一些基本配置文件字段时,我得到了401类似于restapi的ssl必需错误



我正在使用rest api从linkedin中获取带有php代码的基本配置文件数据。我能够成功地生成访问代码和访问令牌,但每当我尝试使用以下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);

我的解决方案是使用https://而不仅仅是http://

最新更新