访问全尺寸(851x315)时间轴封面照片通过图形API随偏移距作物 [英] Accessing full size (851x315) timeline cover photo via graph api with offset crop

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

问题描述

这是一个持续的问题,<一个href=\"http://stackoverflow.com/a/21074207/3269910\">http://stackoverflow.com/a/21074207/3269910

解决方案似乎罚款c0.0.851.315

the solution seems fine c0.0.851.315

但c0.0值指向图像为0x0位置

but the c0.0 values are pointing to 0x0 position of the images

我想是与offset_y形象。如果offset_y:20,

what i want is the image with offset_y . if an offset_y: 20,

也就是说,我想同样大小和图像的一部分,我所看到的我的网页时间表的API调用。

ie, i want the same size and part of image, what i am seeing in my page timeline in a api call.

是否有可能做到这一点?

Is it possible to do this ?

请注意:如果我改变c0.0零值其他一些则是指向像素,但offset_y是%我认为

Note: if i change c0.0 the zero value to some other then it is pointing to pixels but offset_y is % i think.

感谢您的帮助。

推荐答案

我不得不与Facebook平台团队讨论;

I had discussion with Facebook Platform Team;

他们还没有准备好分享手工计算给我们。

They are not ready to share the manual calculation to us.

和是的,这是可以使用自己的API offset_y值手动计算c0.XXXX的价值。

and yes, it is possible to calculate value of c0.XXXX manually using your API offset_y value.

下面是我的PHP code。

Here is my PHP code.

$fb_page_cover_json  =  json_decode( file_get_contents( 'https://graph.facebook.com/11111111?fields=cover'));

$fb_cover_image_url = $fb_page_cover_json->cover->source;

$image_info = getimagesize($fb_cover_image_url);
$image_width = $image_info[0];
$image_height = $image_info[1];                 

echo getTop($fb_page_cover_json->cover->offset_y,$image_width,$image_height);


function getTop($offset_y,$image_width,$image_height) {
    $cover_w = 851;
    $cover_h = 315;
    $img_w = $image_width;
    $img_h = $image_height;
    $real_img_h = ($cover_w * $img_h / $img_w) - $cover_h;
    $result = ($real_img_h * $offset_y / 100 * -1);

    return floor($result);
}

该方法共达将返回c0.XXX值。

The method getTop will return the c0.XXX value.

希望这有助于一些之一。

Hope this helps some one.

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

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