PHP开发遇到的小坑

1. 在领英接口中,需要上传二进制图片,下面使用guzzlehttp实现

$options = [
  'headers' => ['Content-Type' => 'text/binary','X-Restli-Protocol-Version'=>'2.0.0','Authorization' => 'Bearer '.$accessToken['access_token'],],
  'body' => fopen($file, 'r'),
];
$client = new Client();
$response = $client->request('POST', $url, $options);
$httpCode = $response->getStatusCode();

需要注意: 'Content-Type' => 'text/binary'  必须是binary

原文地址:https://www.cnblogs.com/tgzmos/p/14722416.html