doupaoshu8334 2019-05-10 13:34
浏览 235

在Linkedin API上创建一个图像共享

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" "

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?