user3587946
user3587946

Reputation: 83

Get user shared video data from Facebook graph api

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

Upvotes: 0

Views: 1150

Answers (2)

Hardik Thakkar
Hardik Thakkar

Reputation: 15951

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:

Upvotes: 1

Nitin Gohel
Nitin Gohel

Reputation: 49710

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

enter image description here

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

Upvotes: 1

Related Questions