0

I am using the following script to download the photos.

$data = file_get_contents($photos->pic_big);
$file = fopen($image_save, 'w+');
fputs($file, $data);
fclose($file);

But I want to now download the image resized according to my use. Facebook gives an option for this.

https://graph.facebook.com/shaverm/picture?width=200&height=200

Can i replace the username with user id to get the re-sized picture? How do i write script in PHP which will download that photo to my server?

Mahesh
  • 1,503
  • 3
  • 22
  • 33

1 Answers1

0

Yes, you can replace the username with user's ID.

The username is in real an alias for object ID in Facebook Graph. Try out this: https://developers.facebook.com/tools/explorer/

You can download the photo for e.x. using curl: https://stackoverflow.com/a/6476232/1815881.

Community
  • 1
  • 1
Athlan
  • 6,389
  • 4
  • 38
  • 56
  • Do i need to pass any access_token? – Mahesh Mar 23 '13 at 16:51
  • No. Profile pictures are public in Graph. Just use an URL. – Athlan Mar 23 '13 at 16:52
  • Like many APIs at Facebook, access to pictures are rate limited to prevent abuse. It's a very common problem for applications to run into rate limits with pictures when an application becomes even slightly popular. The best way to avoid rate limiting problems is to pass an access_token=token parameter along with the request. – Mahesh Mar 23 '13 at 17:00
  • why do you prefer curl instead of file_get_contents? – Mahesh Mar 23 '13 at 17:16
  • Because of performance, many options to set, multirequests (at the same time) and so one. http://stackoverflow.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance – Athlan Mar 23 '13 at 17:21
  • Do i need any special permission to profile picture? It is working for my account without any permissions. – Mahesh Mar 24 '13 at 05:09