通过图形API访问全尺寸(851x315)时间轴封面照片 [英] Accessing full size (851x315) timeline cover photo via graph api

查看:134
本文介绍了通过图形API访问全尺寸(851x315)时间轴封面照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当我通过Graph API(使用PHP)访问时间轴封面照片URL时,返回的照片是720x266而不是851x315.使用<graph api url>/userId/?field=cover或通过访问<graph api url>/userID

I notice that when I access the timeline cover photo URL via the Graph API (using PHP) the photo returned is 720x266 instead of 851x315. Either using, <graph api url>/userId/?field=cover or by accessing the url in ['cover']['source'] of the json array returned when accessing <graph api url>/userID

我一直无法找到检索全尺寸封面照片的方法.使用萤火虫,我可以看到Facebook加载了全尺寸851x315的图片,URL的唯一区别似乎是API返回的路径的路径为720x720,

I've been unable to find a way to retrieve the full size cover photo. Using firebug I can see Facebook load the full size 851x315 image, the only difference in the URL seems to be that the one returned by the API has 720x720 in the path,

http://a3.sphotos.ak.fbcdn. net/hphotos-ak-prn1/xxxxxx_xxxxxxxxxxxxxxx_xxxxxxxxxx_n.jpg

Graph API返回的内容

http://a3.sphotos.ak. fbcdn.net/hphotos-ak-prn1/s720x720/xxxxxx_xxxxxxxxxxxx_xxxxxxxxxx_n.jpg

有没有一种方法可以直接访问该全尺寸封面照片URL?我可以解析API返回的URL,以去除720x720,但我希望这是一种直接获取全尺寸封面照片URL的更优雅的方法.

Is there a way way I can access that full size cover photo URL directly? I could parse the URL returned by the API to strip the 720x720 but I am hoping the is a more elegant way of obtaining the full size cover photo URL directly.

推荐答案

访问Facebook用户的完整时间轴封面照片


在php中,我们可以执行以下操作. 它是一个小技巧,我不保证它将终身有效.

Accessing full-size timeline cover photo of facebook user


In php , we can do the following. Its a small hack,and i dont gurantee that it will work for lifetime.

如您所见,返回的照片URL中有一个s720x720.现在,我们将其替换为l720(L720).借助于php中的preg_replace().

As you can see, there is a s720x720 in the returned photo url. Now we are going to replace that with l720 (L720). with the help of preg_replace() in php .

$coverphoto_url="https://a3.sphotos.ak.fbcdn.net/hphotos-ak-prn1/s720x720/xxxxxx_xxxxxxxxxxxxxxx_xxxxxxxxxx_n.jpg";

$coverphoto_url = preg_replace('/s720/i','l720',$coverphoto_url);


这将返回


This will return,

https://a3.sphotos.ak.fbcdn.net/hphotos-ak-prn1/ l720x720 /xxxxxx_xxxxxxxxxxxxxxx_xxxxxxxxxx_n.jpg

https: //a3.sphotos.ak.fbcdn.net/hphotos-ak-prn1/l720x720/xxxxxx_xxxxxxxxxxxxxxx_xxxxxxxxxx_n.jpg


您也可以使用javascript.


You can also do this with javascript.

coverphoto_url = coverphoto_url.replace(/s720/i, 'l720');


如果您不知道如何通过图形API检索封面照片,请阅读此问题.


If you dont know how to retrieve coverphoto via graph API,then please read this question.

如何获取securl封面URL?

希望这对某人有帮助:)

hope this helps someone :)

这篇关于通过图形API访问全尺寸(851x315)时间轴封面照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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