我正在使用PHPUnit测试一套REST Web服务.我们正在使用输出缓冲来对响应进行gzip编码.当我使用PHPUnit运行服务测试时,我收到错误:
Cannot modify header information - headers already sent by (output started at /home/dotcloud/php-env/share/php/PHPUnit/Util/Printer.php:172)
Run Code Online (Sandbox Code Playgroud)
它抱怨我的代码echo是浏览器的输出...
通过ob_start()在测试类的顶部添加一个调用,我能够暂时解决这个问题,但是当我一次运行多个测试时,我再次收到此错误.
有任何想法吗?
我熟悉用于处理后台工作的php-resque和其他工作处理系统,但我不认为它会做我需要的工作.
在这种情况下,我有一个传入的Web服务请求,需要对外部系统执行多个(2-4)独立调用,并返回到客户端的综合响应.每个标注可能需要300-500ms,因此我希望每个标注并行执行,以便整个过程不超过500ms +/-总计.
我的php-resque和其他系统的问题是等待甚至1秒开始发出这些标注太长时间不能等待,我正在考虑另一种方法.
我在想什么:
当然,我们会为每个请求和整个过程实施超时...
思考?我错了吗?php-resque几乎可以立即启动多个并行工作吗?
我知道之前已经问过,但其他帖子中的建议没有帮助.我成功从谷歌收到了授权令牌,但是当我尝试获取访问令牌时,我收到了invalid_request.
我们在PHP中的第一次尝试产生了响应,当我通过我的HTTP客户端尝试它时,我得到了同样的结果.最后,我直接尝试使用CURL,但仍然得到了相同的结果:
curl -v -k --header "Content-Type: application/x-www-form-urlencoded" \
-F 'code=4/U2su0fwiynq4v8J8xD56ohfF0fX6.EhP0brx3cosbuJJVnL49Cc8EFE7ncQI' \
-F 'client_id=012345678901-abcdefghijklmnopqrstuvwxyz012345.apps.googleusercontent.com' \
-F 'client_secret=ABC123ABC123ABC123ABC123' \
-F 'grant_type=authorization_code' \
-F 'redirect_uri=https://app.myserver.com/googleLogin.php' \
https://accounts.google.com/o/oauth2/token
Run Code Online (Sandbox Code Playgroud)
我收到的回复是:
> https://accounts.google.com/o/oauth2/token
* About to connect() to accounts.google.com port 443 (#0)
* Trying 173.194.77.84... connected
* Connected to accounts.google.com (173.194.77.84) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, …Run Code Online (Sandbox Code Playgroud) 我觉得我错过了一些愚蠢的事......
我正在使用PHP SDK为新的Gmail API提取电子邮件中的附件.我可以获得附件内容,但除非它是文本文件,否则我无法在保存文件后打开它.如果附件是PDF,则不会呈现.如果是excel文件,则无法打开.
我究竟做错了什么?
// this works; I get the attachment body, etc
$data = $g->gmail->users_messages_attachments->get($email_account, $email_message_id, $p->getBody()->getAttachmentId());
$fh = fopen(DOC_ROOT."/file.pdf", "w+");
fwrite($fh, base64_decode($data->data));
fclose($fh);
Run Code Online (Sandbox Code Playgroud)