I'm not able to Create an Image Share, can you put some example code please or check my code.
I've already tried "Create a Text Share", "Create an Article or URL Share" on this link : https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin (it work's)
I need to show if my code is good
I have create register_image() which work's well
Now I want to upload_image
public function upload_image($src_path, $image_request) {
if(!file_exists($src_path)) return -1;
$ch = curl_init();
if ($ch === false) {
throw new Exception('failed to initialize');
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $image_request['value']['uploadMechanism']['com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest']['uploadUrl'] . "&oauth2_access_token=" . $this->_access_token);
$postData = array(
'upload-file' => $src_path,
);
$str = http_build_query($postData);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if ($response === false)
$response = curl_error($ch);
return $this->share_v3($image_request);
}
I get this error :
string(493) "HTTP/1.1 400 Bad Request Server: Play Set-Cookie: lang=v=2&lang=en-us; Path=/; Domain=api.linkedin.com Date: Fri, 10 May 2019 14:44:21 GMT Content-Length: 0 X-Li-Fabric: prod-lva1 Connection: keep-alive X-Li-Pop: prod-tln1 X-LI-Proto: http/1.1 X-LI-UUID: K6iDroJZnRXA+wxRVysAAA== Set-Cookie: lidc="b=VB41:g=2116:u=177:i=1557499460:t=1557553413:s=AQGsGR5wiWjwizsvGJEYdFeoQj-7IVF1" X-LI-Route-Key: "b=VB41:g=2116:u=177:i=1557499460:t=1557553413:s=AQGsGR5wiWjwizsvGJEYdFeoQj-7IVF1" "