可以通过Zend HTTP Client下载文件吗? [英] Possible to download a file through the Zend HTTP Client?

查看:118
本文介绍了可以通过Zend HTTP Client下载文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个脚本,使用Zend http客户端下载文件: http://framework.zend.com/manual/en/zend.http.html 但我找不到它说的如何做到这一点,所以我想知道它是否可能..该文件依赖于登录,因此我需要通过zend http客户端完成它,以便它可以利用脚本登录时创建的cookie。

I am trying to build a script where it downloads a file using the Zend http client: http://framework.zend.com/manual/en/zend.http.html but I can't find anywhere where it says how to do this so I'm wondering if its possible... The file is dependent on being logged in so I need to have it done through the zend http client so it can make use of the cookies that are created when the script logs in..

非常感谢任何建议

推荐答案

完成文件请求,就像您对网页一样。响应的主体应包含文件的二进制数据(如果您正在下载 CSS,XML等文件,则可能包含文本数据)。

Complete the request for the file just like you would a webpage. The body of the response should contain the binary data for the file (or possibly text data if you were downloading a CSS, XML, etc... file).

$body = $response->getBody();
file_put_contents("myfile.zip",$body);

这篇关于可以通过Zend HTTP Client下载文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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