PHP Facebook Image Proxy
I need to figure out how to create a simple image proxy for Facebook. The end goal is to be authenticated as myself with my access token saved, used the Facebook PHP lib to grab photos that I am tagged in, and then display those on my wordpress site.
I've got everything working, I just need to figure out how to show these images via a proxy so users who are not authenticated / do not h开发者_高级运维ave access normally to see them will be able to.
I'm looking for something that is basically: img src="/fb-proxy.php?uid=some-fb-photo-id"
I don't want to download the files on to my server, but want to do this all on the fly in memory.
You could swap $json_details['picture']
for $json_details['source']
if you wanted the original version of the photo.
<?php
$access_token = 'HARD CODED ACCESS TOKEN';
$picture_id = $_REQUEST['pid'];
$json_details = json_decode(
file_get_contents(
"https://graph.facebook.com/".$picture_id."?access_token=".$access_token),
true);
header('Content-type: image/jpeg');
$picture = $json_details['picture'];
echo file_get_contents($picture);
?>
You could call this just as your suggest, but instead use pid
instead of uid
, where pid
is a facebook photo id.
精彩评论