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

上传多媒体文件出现错误,一直返回false,但是发送客服消息成功

Open Osub opened this issue 10 years ago • 6 comments

data数组: array(1) { ["media"]=> string(23) "@C:\fakepath\lamian.jpg" }

type:'image'

返回 false

Osub avatar Feb 11 '15 03:02 Osub

php版本多少,高版本的使用上传方式不一样

binsee avatar Feb 11 '15 06:02 binsee

@binsee 5.3.3 应该怎么上传?

我可以获取到接收消息的类型,但是自动回复 提示 该公众号暂时无法提供服务 ,获取服务器ip列表正常,获取发送的语音也正常。不过视频也有点问题。不知道是我哪里弄错了。还是不兼容呢?

Osub avatar Feb 11 '15 08:02 Osub

@Osub 当你调用上传方法失败后,获取下错误码和错误文本是什么。 $weObj->errCode $weObj->errMsg

binsee avatar Feb 11 '15 08:02 binsee

@binsee 我试试,谢谢指导

Osub avatar Feb 11 '15 08:02 Osub

你可能是路径问题,尝试把反斜杠 '' 改为斜杠 '/' 。 我也尝试过上传图片,当路径不对时,http_post会返回错误,根据uploadMedia的代码来看,此时并不会返回errCode和errMsg数据。

public function uploadMedia($data, $type){ if (!$this->access_token && !$this->checkAuth()) { $this->log("uploadMedia, checkAuth failed"); return false; } //原先的上传多媒体文件接口使用 self::UPLOAD_MEDIA_URL 前缀 $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_UPLOAD_URL.'access_token='.$this->access_token.'&type='.$type,$data,true); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; $this->log("uploadMedia failed," . "errCode=" . $this->errCode . ",errMsg=" . $this->errMsg); return false; } return $json; } $this->log("uploadMedia, failed"); return false; }

coneo avatar Apr 21 '15 11:04 coneo

如果调用uploadMedia 返回失败,请使用$weObj->errCode来获取错误码

binsee avatar Apr 22 '15 02:04 binsee