在Linkedin API上创建图像共享

时间:2019-05-10 13:34:40

标签: php api linkedin

我无法创建图片共享,请输入示例代码还是检查我的代码。

我已经在以下链接上尝试过“创建文本共享”,“创建文章或URL共享”:https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin(有效)

我需要证明我的代码是否正确

我创建了好用的register_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);


}

我收到此错误:

  

string(493)“ HTTP / 1.1 400错误的请求服务器:播放Set-Cookie:lang = v = 2&lang = en-us; Path = /; Domain = api.linkedin.com日期:2019年5月10日,星期五14 :44:21 GMT内容长度:0 X-Li-Fabric:prod-lva1连接: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“”

0 个答案:

没有答案