0

如果它的高度和宽度> = 某物,如何获取源值

我的工作:我使用 facebook graph api 来获取这些值.. 它的输出为 json 对象.. 这不是问题,我只需要获取一个链接意味着它的宽度必须给定值的源值。

或者如果可以在 facebook 图表中给出条件会更容易

我的代码:

$url = "https://graph.facebook.com/{$this->post[id]}?fields=images&access_token={$this->user->token}";
$url = file_get_contents($url);
$link = (array)json_decode($url);

假设我想获得源值,它的高度应该> 420 ...

Array
(
    [images] => Array
        (
            [0] => stdClass Object
                (
                    [height] => 1152
                    [width] => 2048
                    [source] => https://sphotos-b.xx.fbcdn.net/hphotos-snc6/256375_463526207001195_392636722_o.jpg
                )

            [1] => stdClass Object
                (
                    [height] => 540
                    [width] => 960
                    [source] => https://sphotos-b.xx.fbcdn.net/hphotos-ash4/427440_463526207001195_392636722_n.jpg
                )

            [2] => stdClass Object
                (
                    [height] => 405
                    [width] => 720
                    [source] => https://sphotos-b.xx.fbcdn.net/hphotos-ash4/s720x720/427440_463526207001195_392636722_n.jpg
                )

            [3] => stdClass Object
                (
                    [height] => 337
                    [width] => 600
                    [source] => https://sphotos-b.xx.fbcdn.net/hphotos-ash4/s600x600/427440_463526207001195_392636722_n.jpg
                )

            [4] => stdClass Object
                (
                    [height] => 270
                    [width] => 480
                    [source] => https://sphotos-b.xx.fbcdn.net/hphotos-ash4/s480x480/427440_463526207001195_392636722_n.jpg
                )

            [5] => stdClass Object
                (
                    [height] => 180
                    [width] => 320
                    [source] => https://sphotos-b.xx.fbcdn.net/hphotos-ash4/s320x320/427440_463526207001195_392636722_n.jpg
                )

            [6] => stdClass Object
                (
                    [height] => 101
                    [width] => 180
                    [source] => https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/427440_463526207001195_392636722_a.jpg
                )

            [7] => stdClass Object
                (
                    [height] => 73
                    [width] => 130
                    [source] => https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/427440_463526207001195_392636722_s.jpg
                )

            [8] => stdClass Object
                (
                    [height] => 73
                    [width] => 130
                    [source] => https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/s75x225/427440_463526207001195_392636722_s.jpg
                )

        )

    [id] => 463526207001195
    [created_time] => 2012-08-19T16:22:21+0000
)
4

1 回答 1

0

You can specify the width and height parameters in the graph api call to retrieve the picture in alternate sizes.
eg - https://graph.facebook.com/4/picture?width=300&height=420
Please refer to this blog post for more details -
https://developers.facebook.com/blog/post/2012/08/22/platform-updates--operation-developer-love/

于 2012-09-10T22:22:53.597 回答