Get user shared video data from Facebook graph api

天大地大妈咪最大 提交于 2020-01-16 19:17:04

问题


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


回答1:


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




回答2:


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:



来源:https://stackoverflow.com/questions/24198357/get-user-shared-video-data-from-facebook-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!