Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:如何获取Facebook相册照片的选取器_Ios_Objective C_Swift_Facebook Graph Api_Facebook Ios Sdk - Fatal编程技术网

iOS:如何获取Facebook相册照片的选取器

iOS:如何获取Facebook相册照片的选取器,ios,objective-c,swift,facebook-graph-api,facebook-ios-sdk,Ios,Objective C,Swift,Facebook Graph Api,Facebook Ios Sdk,Facebook iOS SDK是否像UIImagePickerController那样提供任何默认的Facebook相册照片选择器 我从很久以前就听说了,所以一直在寻找,但什么也没找到 如果有人对此有任何想法,请告诉我。如果不是,那么我肯定需要自己制作。Facebook iOS SDK目前还没有提供这样的功能。相反,我发现了一个第三方类,它做完全相同的事情 从Facebook导入 在没有第三方工具的情况下,使用graph api 2.4、2.5、2.6、2.7、2.8和facebook gra

Facebook iOS SDK是否像UIImagePickerController那样提供任何默认的Facebook相册照片选择器

我从很久以前就听说了,所以一直在寻找,但什么也没找到


如果有人对此有任何想法,请告诉我。如果不是,那么我肯定需要自己制作。

Facebook iOS SDK目前还没有提供这样的功能。相反,我发现了一个第三方类,它做完全相同的事情

从Facebook导入

在没有第三方工具的情况下,使用graph api 2.4、2.5、2.6、2.7、2.8和facebook graph api 2.10从相册中获取facebook照片

1在Facebook开发者帐户中添加应用程序

2然后选择应用程序中的平台以便更好地理解,请参见下面的屏幕截图

3选择ios并在向导中显示所有步骤

4然后转到图形api探索

5在图形api资源管理器中选择您的应用程序,以了解更多显示屏幕截图

6单击Get token..然后单击Get token中的Get access token,您可以看到许多权限,以便更好地理解和查看图像

7用于在屏幕截图后检查是否允许打开或关闭相册名称和图像

如果“用户照片”权限未打开,则显示错误请参见以下屏幕截图

完成步骤7后,请执行以下步骤或下载编码文件。我把链接放在你可以下载的地方

目标c的编码文件

8如果没有错误显示,则在视图控制器的viewDidLoad方法中显示以下代码。此代码用于获取唱片集名称和唱片集ID

目标C

9现在获取相册封面照片,请在tableview单元格中键入以下行的代码

目标C

10现在获取相册照片id的代码

 // code in **table didselect method**
目标C

11另一个视图控制器一个用于在集合视图cellforRow中获取图像的代码

目标C

12获得数据后,您必须在facebook上提交应用程序,以便提交,您可以填写信息

1应用程序详细信息

2现状与回顾

=====

如果你有任何疑问,我会帮助你


享受.happy编码。

谢谢,但是我如何才能使用静态用户登录?我想输入用户名和密码手册,这样我的视图控制器就不会显示登录弹出窗口,但总是从我设置的facebook页面获取相册。你能不能也共享Swift文件。@Maulik你有Swift 3代码吗?我几乎完成了,但是我的照片中出现了一个不寻常的错误,这是我测试过的
 coverid = [NSString stringWithFormat:@"/%@?fields=picture",[ids objectAtIndex:indexPath.row]]; **// pass album ids one by one**


/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:coverid
                              parameters:nil
                              HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error)
 {

    // NSLog("%@",result);

     NSDictionary *pictureData  = [result valueForKey:@"picture"];

     NSDictionary *redata = [pictureData valueForKey:@"data"];

     urlCover = [redata valueForKey:@"url"];



     NSURL *strUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",urlCover]];

     NSData *data = [NSData dataWithContentsOfURL:strUrl];
     UIImage *img = [[UIImage alloc] initWithData:data];
     UIImageView *img1;

     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
     {
         img1= [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 50, 50)];
     }
     else
     {
         img1= [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 40, 40)];
     }



     [img1 setImage:img];
     [img1 setContentMode:UIViewContentModeScaleAspectFit];
     [cell.contentView addSubview:img1];


 }];
 // code in **table didselect method**
   NSString *strAlbumid = [NSString stringWithFormat:@"/%@/photos",[ids objectAtIndex:indexPath.row]];



FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:strAlbumid
                              parameters:nil
                              HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {

    // NSLog("%@",result);
    NSDictionary *data = [result valueForKey:@"data"];

    arrId = [data valueForKey:@"id"];



    PhotoViewControllerr *photoViewcontroller;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        photoViewcontroller = [[PhotoViewControllerr alloc]initWithNibName:@"PhotoViewController_Ipad" bundle:nil];
    }
    else
    {
        photoViewcontroller = [[PhotoViewControllerr alloc]initWithNibName:@"PhotoViewController" bundle:nil];
    }


    photoViewcontroller.picsArray = arrId;

    [photoViewcontroller.navigationController setNavigationBarHidden:YES];




    [[self navigationController] pushViewController:  photoViewcontroller animated:YES];


}];
NSString *strAlbumid = [NSString stringWithFormat:@"/%@/?fields=images",[self.picsArray objectAtIndex:indexPath.row]];



FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:strAlbumid
                              parameters:nil
                              HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error)
{

    //NSLog("%@",result);
    picture_images = [result valueForKey:@"images"];

    NSMutableArray *picCount = [picture_images objectAtIndex:picture_images.count - 1];



     NSURL *strUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[picCount valueForKey:@"source"]]];


    dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(q, ^{
        /* Fetch the image from the server... */
       NSData *data = [NSData dataWithContentsOfURL:strUrl];
         UIImage *img = [[UIImage alloc] initWithData:data];
         dispatch_async(dispatch_get_main_queue(), ^{

         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
         {

         img1= [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
         }
         else
         {

         img1= [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
         }



         img1.image = img;
         img1.contentMode = UIViewContentModeScaleAspectFit;
         [cell.contentView addSubview:img1];

         });
         });



}];