php file_get_contents失败但ping工作正常

时间:2013-04-07 08:51:49

标签: php twitter file-get-contents ping

我正在尝试编写一个非常简单的php脚本来测试主机api.twitter.com是否已启动。但是当我做的时候

file_get_contents('https://api.twitter.com')

然后我收到错误

Warning: file_get_contents(https://api.twitter.com):
failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found

命令行上的简单ping工作正常,file_get_contents可以在其他网址上正常工作,例如http://google.com

在我尝试curl之前,我想我会看到我在file_get_contents()做错了吗?

1 个答案:

答案 0 :(得分:0)

https://api.twitter.com本身确实会返回404 - 正常情况。如果您想与API进行交互,则必须使用以下内容:

https://api.twitter.com/1.1/statuses/mentions_timeline.json

文档:https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline