Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php curl upload linkedin image

// 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);
Comment

PREVIOUS NEXT
Code Example
Php :: divi layout injector shortcode module in function php file 
Php :: php spellchecker 
Php :: MForm Bild Attribute 
Php :: Gsuite integration in Laravel PHP 
Php :: php pop up message 
Php :: php crash course could not find driver 
Php :: Including ACF in a custom theme or plugin 
Php :: convert a value to a float in php 
Php :: sail laravel mix hot 
Php :: Cant find AddHandler of PHP inside Apache configuration files 
Php :: WP Admin Bar Dev Links 
Php :: laravel error not responding well 
Php :: pass yield to vue component laravel 
Php :: Prevent infinite loop when saving Statamic entry 
Php :: html vs php 
Php :: [name] 
Php :: Fehler beim Uploadtest der ausgewählten Datei. 
Php :: Command "make:auth" is not defined. 
Php :: file upload yii2 rest api 
Php :: symfony request 
Php :: laravel echo server 
Php :: dequeue recaptcha wordpress 
Php :: write to error log opencart 
Php :: <= in php 
Php :: fetch data from database withour restarting console php 
Php :: php if 2 files in dir unlink the olderst 
Php :: illuminate routing array to string conversion 
Php :: laravel softdeletes not working giving empty data 
Php :: @parent laravel 
Php :: php if condition 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =