wechat-php-sdk icon indicating copy to clipboard operation
wechat-php-sdk copied to clipboard

有人研究过微信小店的图片上传接口吗

Open dmx8895 opened this issue 11 years ago • 14 comments
trafficstars

文档里面图片数据的参数是post数据,这要怎么弄 qq 20141008224048

dmx8895 avatar Oct 08 '14 14:10 dmx8895

https://github.com/dodgepudding/wechat-php-sdk/blob/master/wechat.class.php#L1037

lichunqiang avatar Oct 09 '14 01:10 lichunqiang

这个是高级接口里的多媒体上传,微信小店的和他不一样。这个接口的请求参数里面的图片数据的参数叫POST数据,这算什么意思。

dmx8895 avatar Oct 14 '14 07:10 dmx8895

看来是文档写的不够全?没有对POST数据说明

lichunqiang avatar Oct 14 '14 09:10 lichunqiang

应该是一样的吧

binsee avatar Oct 14 '14 10:10 binsee

话说,没有人写微信小店的类库代码啊?

binsee avatar Oct 14 '14 10:10 binsee

是不一样的,我试了很多都是报-1的错。找了官方的客服,他们完全不处理技术上的问题。不知道哪位朋友能联系上微信的同学。

dmx8895 avatar Oct 14 '14 12:10 dmx8895

难不成是只post图片的二进制数据?

binsee avatar Oct 14 '14 15:10 binsee

post文件有两种方式,一种是post文件格式,另一种是post二进制流,微信那个通用的上传多媒体文件接口过去好像是采用二进制流的格式的,现在改成通用的post文件格式了,但微信小店这里没有说明是哪种格式的,试试直接post二进制数据看看。

dodgepudding avatar Oct 15 '14 04:10 dodgepudding

刚测试了下,成功了,需要post的是图片的二进制数据。

lichunqiang avatar Oct 15 '14 04:10 lichunqiang

不好意思能提供一下代码吗,我试了下还是不行,可能是我哪里代码有问题。

dmx8895 avatar Oct 19 '14 15:10 dmx8895

$body = file_get_contents('path/to/xx.jpg');

//....
//curl 

curl_setopt($oCurl, CURLOPT_POSTFIELDS, $body);

就是获取图片的二进制数据,直接post

lichunqiang avatar Oct 20 '14 01:10 lichunqiang

搞定了,感谢。

dmx8895 avatar Oct 24 '14 14:10 dmx8895

今天一直调试这个接口,一直返回errorcode=-1 我是用JAVA写的 用到HttpClient,怎么解决啊,急死了

lsd1990 avatar Mar 03 '15 13:03 lsd1990

求Java解决方案~~~头疼好几天了

wo8335224 avatar Mar 22 '15 02:03 wo8335224