Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

素材管理 -- 图片下载失败 #12

Closed
lazyou opened this issue Apr 30, 2015 · 6 comments
Closed

素材管理 -- 图片下载失败 #12

lazyou opened this issue Apr 30, 2015 · 6 comments

Comments

@lazyou
Copy link

lazyou commented Apr 30, 2015


  1. overtrue\wechat\src\Wechat\Media.php 的 download() 方法返回是空。

    原因在 overtrue\wechat\src\Wechat\Http.php 的 request() 中

    $contents = json_decode($response['data'], true);

    $response['data']并不是json格式,是图片资源。





  2. download()的返回值

    return $filename ? $contents : file_put_contents($filename, $contents);

    要对换下冒号两边的参数 :

    return $filename ? file_put_contents($filename, $contents) : $contents;

@overtrue
Copy link
Collaborator

overtrue commented May 1, 2015

@lazyou OK。多谢,重构的时候没注意

overtrue added a commit that referenced this issue May 1, 2015
@overtrue overtrue closed this as completed May 1, 2015
overtrue added a commit that referenced this issue May 1, 2015
@lazyou
Copy link
Author

lazyou commented May 1, 2015

下载图片的时候我出现了另一个错误情况。大致原因是在

D:\xampp\htdocs\xampp\meishenghuo\vendor\overtrue\wechat\src\Wechat\Utils\Http.php的 request() 方法下 :

$responseSplit = preg_split('/((?:\r?\n){2})/', $response['response']);

正则分割 header和 body的时候出现了 body被拆分成两部分的情况。
我把正则内的 \r 后面的 ? 问号去掉就能解决问题(不懂为什么)。

$responseSplit = preg_split('/((?:\r\n){2})/', $response['response']);


@overtrue
Copy link
Collaborator

overtrue commented May 1, 2015

是在处理哪个逻辑的时候?

@lazyou
Copy link
Author

lazyou commented May 1, 2015

$media->download($mediaId, $filename); 下载临时素材到本地的时候。
下载失败。

@overtrue
Copy link
Collaborator

overtrue commented May 1, 2015

今天我改完那个bug之后?

@lazyou
Copy link
Author

lazyou commented May 1, 2015

今天改完的还没更新使用。我明天更新下再建个Issues反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants