File_get_content无法打开流

[英]File_get_content failed to open the stream


I have checked previous related threads, but my problem deals with specific readability API. I am trying to get most relavant image from web page. I am using redhttps://www.readability.com/developers/api/parser for that.

我已检查过以前的相关主题,但我的问题涉及特定的可读性API。我试图从网页获得最相关的图像。我正在使用redhttps://www.readability.com/developers/api/parser。

Here is my code:

这是我的代码:

<?php
define('TOKEN', "1b830931777ac7c2ac954e9f0d67df437175e66e");
define('API_URL', "https://www.readability.com/api/content/v1/parser?url=%s&token=%s");
function get_image($url) {
    // sanitize it so we don't break our api url
    $encodedUrl = urlencode($url);

    $TOKEN = '1b830931777ac7c2ac954e9f0d67df437175e66e';
    $API_URL = 'https://www.readability.com/api/content/v1/parser?url=%s&token=%s';
//  $API_URL = 'http://blog.readability.com/2011/02/step-up-be-heard-readability-ideas';
    // build our url
    $url = sprintf($API_URL, $encodedUrl, $TOKEN);
    // call the api
    $response = file_get_contents($url);
    if( $response ) {
        return false;
    }
   $json = json_decode($response);
    if(!isset($json['lead_image_url'])) {
        return false;
    }
    return $json['lead_image_url'];
}

echo get_image('https://www.facebook.com/');

?>

Error:

Warning: file_get_contents(https://www.readability.com/api/content/v1/parser?url=https%3A%2F%2Fwww.facebook.com%2F&amp;token=1b830931777ac7c2ac954e9f0d67df437175e66e): failed to open stream: HTTP request failed! HTTP/1.1 403 FORBIDDEN in F:\wamp\www\inviteold\test2.php on line 16

1 个解决方案

#1


0  

You seem to be getting content from Facebook.

你似乎从Facebook获得了内容。

Due to your error 403 FORBIDDEN, I would say that your parser/code is not authorised to access the facebook page you are accessing and thus you are getting denied due to privacy settings.

由于您的错误403 FORBIDDEN,我会说您的解析器/代码无权访问您正在访问的Facebook页面,因此您将因隐私设置而被拒绝。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2014/01/17/86fa336996b073c8f0d5350aebf6ad1d.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告