我正在使用以下示例并继续从服务器获得100的响应。图像根本不在Square中更新。
发现自: Square Connect API - image upload - Empty Reply From Server code 52 error
https://gist.github.com/tdeck/7118c7128a4a2b653d11
(删除了locationa和item id) 发布到状态为100的https://connect.squareup.com/v1/XXXXXX/items/XXXXXXX/image
我正在使用你的例子以下是我发送给它的变量:这来自wordpress安装。
uploadItemImage(
'https://connect.squareup.com/v1/XXXXX/items/XXXXX/image',
'XXXXXXXXXXX',
'wp-content/uploads/2015/04/imagename.jpg'
)
);
这是我在项目ID和令牌中添加的jpeg得到的卷曲输出被遮盖了。上传的图像比209字节大得多。但这就是发送的全部内容。
[url] => https://connect.squareup.com/v1/me/items/ITEMID/image
[content_type] =>
[http_code] => 100
[header_size] => 71
[request_size] => 288
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 61.486827
[namelookup_time] => 0.114398
[connect_time] => 0.225888
[pretransfer_time] => 1.347979
[size_upload] => 209
[size_download] => 0
[speed_download] => 0
[speed_upload] => 3
[download_content_length] => -1
[upload_content_length] => 209
[starttransfer_time] => 1.396955
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 74.122.189.136
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 192.168.1.117
[local_port] => 60968
[request_header] => POST /v1/me/items/ITEMID/image HTTP/1.1
Host: connect.squareup.com
Accept: */*
Authorization: Bearer TOKEN
Content-Length: 209
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------754042306466c83e
答案 0 :(得分:0)
自从我编写示例代码以来,看起来像是在API中添加了mime类型的检查。要将内容类型标题添加到多部分请求的图像部分,您需要更改
apm install --check
到
curl_setopt($ch, CURLOPT_POSTFIELDS, ['image_data' => "@$image_file"]);
尝试之后,它对我有用。我会更新我的要点以反映这一点。