Get user shared video data from Facebook graph api - ios

I am using Facebook graph api in my app. I want to get user's posted videos. When I login I get basic info. But when i query about posts i only get id in result.
My code is:
-(void)getPosts {
NSMutableDictionary *par = [[NSMutableDictionary alloc]init];
[par setObject:#"posts" forKey:#"fields"];
[FBRequestConnection startWithGraphPath:#"me"
parameters:par
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
)
{
//handle the result
if(!error)
{
NSLog(#"%#",result);
}
else
{
NSLog(#"%#",[error localizedDescription]);
}
}];
}
Please help if I am doing wrong or missing something. Thanks in advance

with the referance from facebook dev API
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/videos
you got Logged in User Video using this method:
/* make the API call */
[FBRequestConnection startWithGraphPath:#"/me/videos"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
}];
it's Filed object is
You need to set first Permission of user_videos as par doc said:
A user access token with user_videos permission is required to see all videos that person is tagged in or has uploaded.
HERE IT IS SAMPLE CODE:
http://www.filedropper.com/fblogin

1) Here is a basic logic to get User's uploaded video...(shows all videos that were published to Facebook by user)
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/videos/uploaded"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
arrFbUserUploadVideos= [result objectForKey:#"data"]; //get all data in NSMutableArray
}];
Note: This will give the video Uploaded by the user..
2) and if you also want video list in which User tag (shows all videos use person is tagged in) in that case
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/videos"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
arrFbUserTagVideos= [result objectForKey:#"data"]; //get all data in NSMutableArray
}];
Note: This will give the video in which user is tag..
HERE IS A REFERENCE LINK:

Related

Fetching facebook friends of user

I am trying to fetch facebook friend list of the user but it returning only count of the friends.Bellow is my code .Is there anything wrong in this code?
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{
[FBRequestConnection startWithGraphPath:#"/me/friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(#"me/friends result=%#",result);
NSLog(#"me/friends error = %#", error.description);
NSArray *friendList = [result objectForKey:#"data"];
//[m_allFriends addObjectsFromArray: friendList];
}];
}
When you registered your app to facebook. Facebook provide only three permission , these permission is by default approved
user_friends Provides access to a person's list of friends that also use your app. This permission is approved by default.
according to this you can get only those friend who use your app.
check this link
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/friends

How I can add summary to this Facebook Request?

I'm getting photo likes with this request, but I want to add the summary which returns to me the total likes count:
NSString *path=[NSString stringWithFormat:#"/%#/likes",IdPhoto];
[FBRequestConnection startWithGraphPath:path
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
}];
How can I add it?
Try with this call:
"/%#/likes?summary=true"
Source: https://developers.facebook.com/docs/graph-api/reference/v2.3/object/likes#read

Fetch user interests and likes from Facebook along with images using Facebook iOS SDK

I want to fetch Facebook logged in user's interests and likes, which I'm able to do.
But I'm not getting the image for pages liked by user or image for user interests.
The following code lets me fetch user likes:
[FBRequestConnection startWithGraphPath:#"/me/likes"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"User interests data: %#",result);
}];
which returns the following json data:
data = (
{
category = "Musician/band";
"created_time" = "2014-08-08T05:09:56+0000";
id = 9770929278;
name = Adele;
},
{
category = "Musician/band";
"created_time" = "2014-08-08T05:02:09+0000";
id = 5027904559;
name = Shakira;
}
);
but, I want images for the pages liked. How can I do that?
Any help would be appreciated.
Thanks in advance.
You can execute 1 more Graph API call for each for the likes:
[FBRequestConnection startWithGraphPath:#"/me/likes"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSArray *data = [result objectForKey:#"data"];
for(NSDictionary *liked in data) {
NSString *page_id = [liked objectForKey:#"id"];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:#"/%#/picture", page_id] parameters:nil HTTPMethod:#"GET" completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// Get your profile pic here
}
}];
}
}];
It will return the public details of Page. See documentation for more information.

Facebook SDK use Graph API version 1.0

There are some differences between the Facebook graph API versions 1.0 and 2.0 that I'm not so fond of so I would like to downgrade to the graph API version 1.0.
Any ideas how to do this?
Here's the code I'm using right now, which makes a call to version 2.0:
[FBRequestConnection startWithGraphPath:#"/me/friends"
parameters:[NSDictionary dictionaryWithObjectsAndKeys:#"20", #"limit", nil]
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Sucess! Include your code to handle the results here
NSLog(#"***** user friends with params: %#", result);
} else {
// An error occurred, we need to handle the error
}
}];
while the above answer is correct you can use
[FBSettings enablePlatformCompatibility: YES];
And all FbRequests target api v1.0 here is the official documentation about this:
https://developers.facebook.com/docs/reference/ios/current/class/FBSettings/
And if you want to target individual request that use of v1.0 of graph api you can specify it like this:
[FBRequestConnection startWithGraphPath:#"v1.0/me/friends"
parameters:[NSDictionary dictionaryWithObjectsAndKeys:#"20", #"limit", nil]
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Sucess! Include your code to handle the results here
NSLog(#"***** user friends with params: %#", result);
} else {
// An error occurred, we need to handle the error
}
}];
And here is the official docs that explains this
https://developers.facebook.com/docs/reference/ios/current/class/FBRequest/
See overrideVersionPartWith: method and Discussion of it
This can be accomplished at the FBRequest level.
You need to create the FBRequest yourself and use overrideVersionPartWith:.
Keep in mind this will only work if your Facebook app was created before the v2.0 API was released. Newer apps are blocked from using the old API at all.
It will look something like this:
FBRequest *request = [FBRequest requestWithGraphPath:#"/me/friends"
parameters:[NSDictionary dictionaryWithObjectsAndKeys:#"20", #"limit", nil]
HTTPMethod:#"GET"];
[request overrideVersionPartWith:#"v1.0"];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Success! Include your code to handle the results here
NSLog(#"***** user friends with params: %#", result);
} else {
// An error occurred, we need to handle the error
}
}];

iOS Facebook SDK get profile cover image

How can i get the cover of a profile with the FacebookSDK in iOS?
[FBRequestConnection startWithGraphPath:#"/me/events?fields=cover"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"%#", result);
}];
you can also get facebook cover pic by simply calling
http://graph.facebook.com/{user_id or page_id}?fields=cover

Resources