douxiao0400 2017-03-05 16:07
浏览 26

如何从youtube v3中读取响应错误

I make a call to get my response and info , and then print it to view all is ok.

$data = file_get_contents( [CALL TO API]  );
$data = json_decode($data, true);
print("<pre>".print_r($data,true)."</pre>");

If the call is good, I will get my result no problem. but while testing, I need to know when it fails and why.

In the online test demo area, I will get this if it fail's.

{
 "error": {
  "errors": [
   {
    "domain": "youtube.subscription",
    "reason": "subscriptionForbidden",
    "message": "The requester is not allowed to access the requested subscriptions."
   }
  ],
  "code": 403,
  "message": "The requester is not allowed to access the requested subscriptions."
 }
}

But I only get a plank page.
So I then decided to look at my return header with

var_dump(headers_list());
var_dump(http_response_code());

This gives me

array(1) { [0]=> string(23) "X-Powered-By: PHP/5.4.7" }
int(200)

As you see, it is giving me a "200" OK header, but not much else. So how can I see what the youtube DEMO page shows me?
This would also be helpful later on for error checking when my site is finished.

  • 写回答

1条回答 默认 最新

  • doujumiao5024 2017-03-05 16:10
    关注
    $data = file_get_contents([CALL TO API]);
    print_r($data); // Will print the response HTTP body
    print_r($http_response_header); // Will print the response HTTP headers
    
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line