首页 文章

安全加载Facebook Profiles 图片

提问于
浏览
7

我正在尝试将来自Facebook的用户 Profiles 图片包含在内,这样可以正常工作,但事情就是当您想要将其包含在受SSL保护的页面上时 . 我找不到从安全位置加载图片的方法 . 使用以下链接到用户 Profiles 照片:

https://graph.facebook.com/<FB_ID HERE>/picture?type=square

即使我使用 https 它也没有奇怪,因为链接只是重定向到图像,例如我的 Profiles 图片:

https://graph.facebook.com/Bazze/picture?type=square

这将得到以下图片:

http://profile.ak.fbcdn.net/hprofile-ak-snc4/161513_633115680_6792455_q.jpg

请注意,这不是一个安全的位置 .

任何人都知道如何通过 https 协议安全地加载 Profiles 图片?

谢谢!

7 回答

  • 1
    • 这是一个安全的位置,它不是一个安全的重定向

    • 所有你能做的就是确保你在调用图形api时使用安全请求,之后Facebook将接管通信并且 nothing 可以完成 .

  • 9

    您可以通过自己的服务器代理它 . 设置一个脚本,从Facebook获取图像,然后通过SSL将其服务回给您 .

    例如

    <?php
        $path=$_GET['path'];
        if (stristr($path, "fbcdn.")==FALSE && stristr($path, "facebook.")==FALSE)
        {
            echo "ERROR";
            exit;
        }
        header("Content-Description: Facebook Proxied File");
        header("Content-Type: image");
        header("Content-Disposition: attachment; filename=".$path);
        @readfile($path);
    ?>
    

    取自

    http://www.permadi.com/blog/2010/12/loading-facebook-profile-picture-into-flash-swf-using-open-graph-api/

    通过https://yourdomainhere.com/proxy.php?path=URLENCODED-IMG-URI访问应通过SSL返回userpic .

  • -1

    那么,https://graph.facebook.com/Bazze/picture?type=square是302重定向到 http :// ....但请注意 https :// ...仍然有效(example) .

    所以看起来一个解决方案是自己解析302,在适当的位置插入's',然后获取图像 . 但在缺点方面,上面的链接页面有证书错误,并没有一个很好的方法来解决这个问题 .

    (我不是说这是一个很好的答案......)

  • 2

    使用 ***http***://graph.facebook.com/Bazze/picture?type=square 而不是 **https**://graph.facebook.com/Bazze/picture?type=square

  • 2

    Add return_ssl_resources=1到您的图表调用:

    https://graph.facebook.com/<FB_ID>/picture?type=square&return_ssl_resources=1
    

    这是获取SSL服务图像的正确方法;重定向将是具有适当SSL证书的https服务器 .


    Update :当您使用https://graph.facebook.com时,Facebook现在会自动为您重定向到https托管的图像,因此不再需要 return_ssl_resources 参数 .

    使用http://graph.facebook.com仍会获得一个http托管的图像 .

  • -2

    302重定向将具有Open Graph API文档中所述的图片URL .

    您需要从:/ http profile.ak.fbcdn.net /更改为:/ https fbcdn-profile-a.akamaihd.net /

    来自:/ http static.ak.fbcdn.net / to:/ https s-static.ak.fbcdn.net /

    我真的认为FB应该在他们的API中做到这一点!!!!

  • 2

    您还可以批量获取安全的配置文件图片,在这种情况下,您必须添加return_ssl_resources = 1参数作为@ josh3736提到 .

    https://graph.facebook.com/?ids=id1,id2,id3,...&fields=picture&return_ssl_resources=1

相关问题