即使公开可见后,我也看不到我的Linkedin Image在提要中的共享。我得到URN作为回报

时间:2019-06-30 20:45:15

标签: linkedin

我正在尝试通过V2在Linkedin上创建图像共享。我将图片上传到数字资产并创建了UGC分享。它会向我返回URN ID,但是当我去Linkedin时,即使通过直接URL也找不到我的共享。

我没有特殊的访问权限,因此无法通过URN检索该共享。

请帮助。

$client = new Client('XXXXXXXXX','XXXXXXXXX');
$client->setAccessToken($profile->token);
$client->setApiHeaders([
    'Content-Type' => 'application/json',
    'x-li-format' => 'json',
    'X-Restli-Protocol-Version' => '2.0.0', // use protocol v2
]);
$client->setApiRoot('https://api.linkedin.com/v2/');


$filemeta = [
    'registerUploadRequest'=>[
        "recipes" => ["urn:li:digitalmediaRecipe:feedshare-image"],
        "owner" => 'urn:li:person:'.$profile->src_id,
        "serviceRelationships" => [
            [
                "relationshipType"=>"OWNER",
                "identifier"=>"urn:li:userGeneratedContent"
            ]
        ]
    ]
];

$mp = $client->post('assets?action=registerUpload',$filemeta);
$uploadUrl = $mp['value']['uploadMechanism']['com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest']['uploadUrl'];
$mediaUrn = $mp['value']['asset'];

// initialise the curl request
$filename = realpath('uploads/jabirbbs@gmail.com/6-min.jpg');
$request = curl_init($uploadUrl);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$profile->token));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt(
    $request,
    CURLOPT_POSTFIELDS,
    array(
      'upload-file' => $filename
    ));
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_exec($request);
curl_close($request);

//media format

$meta = [
    'author'=>'urn:li:person:'.$profile->src_id,
    'lifecycleState' => 'PUBLISHED',
    'specificContent' => [
        'com.linkedin.ugc.ShareContent'=>[
            'media' => [[
                "media" => $mediaUrn,
                "status" => "READY",
            ]],
            'shareCommentary' => [
                'text' => 'Just a dummy post through API.'
            ],
            "shareMediaCategory" => 'IMAGE'
        ]
    ],
    'visibility' =['com.linkedin.ugc.MemberNetworkVisibility'=>'PUBLIC']
];

$response = $client->post('ugcPosts', $meta);
print_r($response);
exit;

我的股票应该增加订阅源。

0 个答案:

没有答案