GAE PHP - URL提取

时间:2014-03-09 19:29:39

标签: google-app-engine

根据调用另一个App Engine应用程序时的文档:

If you are making requests to another App Engine app, you should consider telling the UrlFetch service to not follow redirects when invoking it.

到目前为止,还没有关于如何编辑该功能并告诉服务不遵循重定向的文档,所以有人知道这个技巧吗?

1 个答案:

答案 0 :(得分:0)

您必须设置

follow_redirects = false

调用fetch时。

使用抓取进行标准通话

fetch(url, payload=None, method=GET, headers={}, 
allow_truncated=False, follow_redirects=True, deadline=5,
validate_certificate=False)

follow_redirects改为false ,如下所示

 fetch(url, payload=None, method=GET, headers={}, 
 allow_truncated=False, follow_redirects=False, deadline=5,
 validate_certificate=False)

<强> PHP

$context = [
    'http' => [
    'method' => 'get',
    'header' => "custom-header: custom-value\r\n" . "custom-header-two: custome-value-2\r\n",
    'content' => $data,
    'follow_location' => false,
    ]
];