How to get Securl cover url?

I am trying to get the FBpage cover url 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 http: // ... url, not https: // ... url

any advice?

+1
source share
2 answers

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

Edit: note that this is not FQL (Facebook Query Language), it is just a standard API call.

0
source

After receiving the url, you can replace http with https preg_replace()with PHP.

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

As far as I tested, it works great.

javascript.

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

, -:)

0

All Articles