How to get a securl cover URL?
Asked Answered
D

2

1

I'm tryng to get the cover url of a FBpage using:

$fql_query_url = "https://graph.facebook.com"
    ."/$fb_id[id]?fields=cover"
."";
try {
    $fql_query_result = @file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);
} catch(Exception $o){   }
$cover = $fql_query_obj[cover][source];

I get an http://... url and not the https://... url

any tips?

Dekameter answered 4/12, 2012 at 12:2 Comment(4)
developers.facebook.com/docs/reference/api/#picturesAyurveda
Why not you replace http:// to https://Racecourse
Because looks like the FB secure url is different.Dekameter
If a try to get the cover source in the develore tools I get a different subdomain secure urlDekameter
S
0

As @CBroe pointed out, you need to specify you need a secure URL by setting the return_ssl_resources argument to 1: https://graph.facebook.com/wtf.no.username/picture?return_ssl_resources=1.

Edit: Please note that this isn't FQL (Facebook Query Language), this is just a standard API call.

Sidra answered 4/12, 2012 at 13:27 Comment(0)
H
0

After getting the url, you can replace http to https with preg_replace() in PHP.

$cover = $fql_query_obj[cover][source];
$secure_cover = preg_replace('/^http(?=:\/\/)/i','https',$cover);

As far as i tested, it works fine.

You can also change this with javascript.

cover = cover.replace(/^http:\/\//i, 'https://');

hope this help someone :)

Hola answered 16/1, 2013 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.