打开流失败:连接超时错误-Themoviedb [英] failed to open stream: Connection timed out error - Themoviedb

查看:591
本文介绍了打开流失败:连接超时错误-Themoviedb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关电影db API的帮助.我不断收到连接超时错误.下面是我的代码,我试图仅输出原始的json响应,以便可以从那里开始工作.

I need some help with the movie db api. I constantly get a connection timed out error. Below is my code, I'm trying to just output the raw json respone so I can work my way from there.

$header_opt = array(
  'http'=>array(
  'method'=>"GET",
  'header'=>"Accept: application/json\r\n" .
            "Content-Type: application/json\r\n"
          )
);

$headers = stream_context_create($header_opt);

$rawjson = file_get_contents('http://api.themoviedb.org/3/movie/tt0076759?api_key=myapikey', false, $headers);

$cleansjon = json_decode($rawjson);

echo $cleansjon;

这是我得到的错误.

Warning: filegetcontents(http://api.themoviedb.org/3/movie/tt0076759?api_key=myapikey) [function.file-get-contents]: failed to open stream: Connection timed out in /*///*/public_html/index.php on line 11

我希望有人可以帮助我.

I hope that someone can help me with this.

添加了HAR响应

{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "WebInspector",
      "version": "537.20"
    },
    "pages": [
      {
        "startedDateTime": "2013-01-27T09:51:02.534Z",
        "id": "page_1",
        "title": "http://*MyWebsite*/tmdb.php",
        "pageTimings": {
          "onContentLoad": 60636,
          "onLoad": 60635
        }
      }
    ],
"entries": [
  {
    "startedDateTime": "2013-01-27T09:51:02.534Z",
    "time": 60197,
    "request": {
      "method": "GET",
      "url": "http://*MyWebsite*/tmdb.php",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "DNT",
          "value": "1"
        },
        {
          "name": "Accept-Encoding",
          "value": "gzip,deflate,sdch"
        },
        {
          "name": "Host",
          "value": "*MyHost*"
        },
        {
          "name": "Accept-Language",
          "value": "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4"
        },
        {
          "name": "User-Agent",
          "value": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.20 (KHTML, like Gecko) Chrome/25.0.1328.0 Safari/537.20"
        },
        {
          "name": "Accept",
          "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        },
        {
          "name": "Cache-Control",
          "value": "max-age=0"
        },
        {
          "name": "Connection",
          "value": "keep-alive"
        },
        {
          "name": "Accept-Charset",
          "value": "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
        }
      ],
      "queryString": [],
      "cookies": [],
      "headersSize": 443,
      "bodySize": 0
    },
    "response": {
      "status": 200,
      "statusText": "OK",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "Date",
          "value": "Sun, 27 Jan 2013 09:51:02 GMT"
        },
        {
          "name": "Content-Encoding",
          "value": "gzip"
        },
        {
          "name": "Server",
          "value": "Apache/2"
        },
        {
          "name": "Vary",
          "value": "Accept-Encoding,User-Agent"
        },
        {
          "name": "Content-Type",
          "value": "text/html"
        },
        {
          "name": "Connection",
          "value": "Keep-Alive"
        },
        {
          "name": "Keep-Alive",
          "value": "timeout=1, max=100"
        },
        {
          "name": "Content-Length",
          "value": "260"
        }
      ],
      "cookies": [],
      "content": {
        "size": 342,
        "mimeType": "text/html",
        "compression": 82
      },
      "redirectURL": "",
      "headersSize": 234,
      "bodySize": 260
    },
    "cache": {},
    "timings": {
      "blocked": 0,
      "dns": 13,
      "connect": 29,
      "send": 0,
      "wait": 60147,
      "receive": 5,
      "ssl": -1
    },
    "pageref": "page_1"
  }
   ]
  }
 }

推荐答案

也许根本没有问题.您的应用程序正在尝试连接到服务器,并收到超时错误.

Maybe there is no problem at all. Your application is trying to connect to a server and gets a timeout error.

这篇关于打开流失败:连接超时错误-Themoviedb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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