PHP Curl Téléchargez l'image LinkedIn

// Working example of uploading image to share on linkedin 
//https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin?context=linkedin/marketing/context#creating-a-share-on-linkedin
$uploadUrl = $r->value->uploadMechanism->{"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest"}->uploadUrl;
$file_name_with_full_path="/full/path/tofile.png";
$access_token="your_user_access_token_here";

$mimeType= mime_content_type($file_name_with_full_path);
$headers = array(
    'Authorization: Bearer '.$access_token,
    "X-RestLi-Protocol-Version:2.0.0",
    "Content-Type: {$mimeType}"
);
$ch = curl_init($uploadUrl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_USERAGENT,'curl/7.35.0');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($file_name_with_full_path));
$response = curl_exec($ch);
Bald Eagle