小编use*_*601的帖子

file_get_contents 通过 php 失败,通过浏览器工作

我想要实现的目标:
\n向 API 端点发出请求,检索 XML 并随后解析结果。
\n我正在发送一个file_get_contents请求来实现此目的。

\n\n

问题:

\n\n
`file_get_Contents` fails, error:  \n\nWarning: file_get_contents(https://api.twitter.com/1.1/statuses/mentions_timeline.json):\nfailed to open stream: \n        A connection attempt failed because the connected party did not properly \nrespond after a period of time, or established connection failed because \nconnected host has failed to respond. \n
Run Code Online (Sandbox Code Playgroud)\n\n

更新 17/08

\n\n

为了巩固我目前的理解:
\n 1. PHP 失败:
\n1.a 它通过 php (超时)失败
\n1.b 它通过命令行失败(curl -G http://api.eve-central.com/api /quicklook?typeid=34 )
\n1.c file_get_contents
\n1.d file_get_contents w/ create_stream_context

\n\n

2. 有效方法:
\n2.a 通过 …

php curl timeout simplexml file-get-contents

5
推荐指数
1
解决办法
3432
查看次数

标签 统计

curl ×1

file-get-contents ×1

php ×1

simplexml ×1

timeout ×1