Are all Facebook profile pictures JPG? - php

I've been using the PHP GraphObject API from Facebook to get the URL of the user's profile picture, and was just wondering if ALL the Facebook profile pictures are .JPG's ...
I wanted to know this so that I know whether I need to determine the file type before saving it (using file_get_contents() and file_put_contents() etc).
Many thanks.

Related

Android app how to get photos of a specific user

I'm creating a social app similar to instagram on Android studio.
Users will be able to upload and view photos in this app.
The photos are saved on a Cloud in a folder called "ProfileImage" and the URL of the photos is saved on the MySql database, along with the ID of the photo and the user's ID.
To get the photos I would like to use Picasso.
If for example the user A wants to look at his photos, the app will have to show him only his photos, that is I will have to get the URLs of the photos that have the id of the user A.
Picasso to get the photos use the following code Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);
But the problem is that I don't know the specific URL of the photos.
One solution I thought of is to get the URLs of the photos via PHP and pass them into an android variable that I will use as a URL variable for Picasso.
But this solution seems slow to me, in the sense that the photo will not be displayed immediately, but seconds will have to pass.
Can anyone recommend a faster and perhaps better solution than mine?
First of all, Upload your image to server and save image url inside mysql database not image itself. Create one api that returns user info including image url.

How to get a Facebook user's profile picture in php

I'm new to PHP and I have developed a system that automatically applies a watermark to a manually uploaded image. What I want to do is have a user sign in with their Facebook account, have the PHP get their profile picture from graph.facebook.com and then save it on my server under the /images directory.
I've been trying to do this for the past 4 and a half hours but I have no idea what i'm doing. I've tried to use Facebook's User Picture SDK but i have no idea how to apply it (clearly just copying and pasting isn't going to work haha). If someone could please provide me with some code, you certainly be mentioned on the final page.
To show image in page
<img src="//graph.facebook.com/{{fid}}/picture">
To save
$image = file_get_contents('https://graph.facebook.com/'.$fid.'/picture?type=large');
$dir = dirname(__file__).'/avatar/'.$fid.'.jpg';
file_put_contents($dir, $image);
Facebook Graph API
http://graph.facebook.com/abdulla.nilam/picture
You can use graph API to get user's image
https://graph.facebook.com/v2.2/USER_ID/picture?width=500&height=500
USER_ID will be user's Facebook ID.
You can set the width and height as required.

How can i get the profile picture of a user who have registered my website via the facebook social plugin

I have a registration plugin embeded via an iframe on my website, The registration plugin works fine , I am also able to get the unique user_id of each user by using the following line of code in the signed_request file which can be located here
The line of code i use to get the user_id is: $response["user_id"];
Now that i have a unique id of each user, i want a way by which i can get the link to the profile image of that user, i know i can get the thumbnail of the profile picutre
using open graph,
But i am looking for a way by which i can get the link to the complete or the original profile picture, not the thumbnail.
Is there a way this can be done? Using open graph or something like that?
You need user_photos permissions first. Then something like this should do it:
SELECT cover_object_id FROM album WHERE owner=me() and type='profile'
Substitute me() with the user you are querying for.
It returns the photo object that you can then use to pull the full version from.
Make an API call to /user_id/?fields=picture using the access_token in the same signed_request

Facebook API/PHP - Is it possible to change a user's profile image via FB Graph API?

Is it possible to set/change a user's facebook profile image through the graph API?
I can't find a specific API method, but it is possible to upload an image to a user's album (http://developers.facebook.com/docs/reference/api/photo). Can I set the user's profile image to an image uploaded to their album?
Edit:
Same question asked in reference to REST API
Can I set a users profile image using the Facebook API?
No, And here's a comment from a guy at facebook:
The Original Link - you have to press show comments
We can do a trick by uploading user’s photo to Facebook via the API then redirect the user to uploaded photo URL with makeprofile=1 added to the list of query strings:
facebook.com/photo.php?pid=xyz&id=abc&makeprofile=1
Check Auto Change Facebook Profile Picture to get PHP example and demo.
Currently this is possible by redirecting the user to the mobile profile pic change url, https://m.facebook.com/photo.php?fbid=[fb photo id]&prof&ls=your_photo_permalink
The previous work around, using the facebook.com/photo.php?pid=[fb photo id]&makeprofile=1 url no longer works.
To the best of my knowledge and experience: No.
See the "Publishing" section here: http://developers.facebook.com/docs/reference/api/photo
Requires the publish_stream
permission.
To publish a photo, issue a POST
request with the photo file attachment
as multipart/form-data.
You can publish an individual photo to
a user profile with a POST to
http://graph.facebook.com/PROFILE_ID/photos
We automatically create an album for
your application if it does not
already exist. All photos from your
application will be published to the
same automatically created album.
You can publish a photo to a specific,
existing photo album with a POST to
http://graph.facebook.com/ALBUM_ID/photos.
The last sentence states you can publish to an existing album, so if you're trying to update the user's profile picture (not sure from the way you stated your question), try getting the album ID for the user, then publishing to that.

Is it possible to set an Image as a User Profile Picture via FBML or FB PHP SDK?

I am reading the Facebook API and I am google'ing for a method or function to be able to set an image as profile picture.
I need to know if something like this is possible at all.
In the old REST Api you find a note, that it isn't possible to upload a picture into the users profile pic album. But.. is this step required for my transaction?
I would like to know which methods/function I have to take and/or an advice how to code.
(trivial workflow of app: user visits fb-app, user clicks on button, user gets an request-alert to allow action, user gets manipulated picture as own profile picture)
thanks in advance
chris
Sorry, but not is possible. If you take a look here:
http://developers.facebook.com/docs/api
At the "Publishing" section the /PROFILE_ID/picture is not writable even if you can upload a photo to an album.

Categories