Upload video using LinkedIn V2 API

前端 未结 2 1003
北海茫月
北海茫月 2021-01-14 23:15

I am trying to upload a video using LinkedIn API V2 but I am unable to post successfully video to my LinkedIn Individual Account. Please help.

Returning Below Respon

2条回答
  •  梦毁少年i
    2021-01-15 00:06

    I make use of the LinkedIn API from Zoonman to do the client post request, but this is out of the scope of the question.

    Because i could not get the php curl functions to work properly, i am using the command line interface to do the request, and it works! See my code below.

    BUT. even tough the upload works. When i do a request to get the status of the upload, it is still "WAITING_UPLOAD". So i think @augustine jenin is right, that it is not supported yet. (may 2019)

     [
    		"recipes" => [
    			"urn:li:digitalmediaRecipe:feedshare-video"
    		],
    		"owner" => "urn:li:organization:" . $liPageId,
    		"serviceRelationships"=> [
    			[
    				"relationshipType"=> "OWNER",
    				"identifier" => "urn:li:userGeneratedContent"
    			]
    		]
    	]
    ];
        
    $register = $client->post('assets?action=registerUpload', $data);
    
    // get upload url and header
    $uploadUrl = $register["value"]["uploadMechanism"]["com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest"]["uploadUrl"];
    $headers = $register["value"]["uploadMechanism"]["com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest"]["headers"];
        
    $curlHeaders = "";
    foreach($headers as $htype => $header) {
    	$curlHeaders .= ' -H "' . $htype . ':' . $header . '"';
    }
    
    // go upload the image to the url
    $filePath = "/path/to/your/file";
    
    $command = '/usr/bin/curl -v';
    $command .= $curlHeaders;
    $command .= ' --upload-file \'' . $filePath . '\' \'' . $uploadUrl . '\'';
    
    // try it yourself by running this on the command line
    //echo $command;
    
    shell_exec($command);
    
    ?>

提交回复
热议问题