LinkedIn API V2-如何将照片上传为二进制文件 [英] LinkedIn API V2 - How to upload photo as binary file

查看:87
本文介绍了LinkedIn API V2-如何将照片上传为二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在上传带有可见此处.

$post_fields = array(
    'file' => '@' . $_FILES['file-attachment']['tmp_name']
        . ';filename=' . $_FILES['file-attachment']['name']
        . ';type='     . $_FILES['file-attachment']['type']
);

$upload_response = process_curl(array(
    CURLOPT_URL => $upload_url,
    CURLOPT_HEADER => false,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_POSTFIELDS => $post_fields,
    CURLOPT_HTTPHEADER => array('Authorization: Bearer '.$token, 'x-li-format: json','Content-Type: multipart/form-data'),
), true);

这是我的请求的样子.我尝试不使用type=行,但没有任何改变.我收到一个空响应,状态码为400.

This is what my request looks like. I tried without using the type= line but that didn't change anything. I'm getting an empty response and a status code of 400.

我正在使用第1步中的上传URL,所以我知道这应该是正确的.

I'm using the upload URL from step 1 so I know that should be correct.

我的请求怎么了?我正在尝试遵循他们在文档中提供的cURL示例,但是也许我的文件格式不正确?

What about my request looks wrong? I'm trying to follow the cURL example they gave in the documentation, but perhaps the format of my file isn't correct?

我也尝试过使post字段的file参数只是完整的文件路径,但这给出了false的响应.

I have also tried making the file parameter of post fields just be the full file path but that gave a response of false.

我要说的另一件事是文件路径中有空格.

Another thing for me to mention is the file path has spaces in it.

推荐答案

您应包括文件的系统路径,例如:user/myname/image.jpg. 内容类型应为应用程序/二进制

You should include the sytem path of the file eg:user/myname/image.jpg. Content type should be application/binary

这篇关于LinkedIn API V2-如何将照片上传为二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆