2017-10-27 17 views
0

Theta Camera SDK를 사용하여 360 도의 각도로 사진을 찍고 있습니다.페이스 북에 Theta 360 ° 사진을 게시하는 방법

이 사진을 Facebook에 게시하고 싶습니다. 360 사진입니다.

https://github.com/AppCoders-io/Facebook360

당신이 요청했다고 가정하면

  UIImage *image = [UIImage imageNamed:@"IMG_0133.JPG"]; 


     NSString *token = [NSString stringWithFormat:@"%@", [FBSDKAccessToken currentAccessToken].tokenString]; 
     NSDictionary *param = @{@"message": @"test", 
           @"access_token": token, 
            @"photo":image, 
           @"allow_spherical_photo": [NSNumber numberWithBool:true] 

           }; 

     FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] 
             initWithGraphPath:@"me/photos" 
             parameters:param 
             HTTPMethod:@"post"]; 

     [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, 
               id result, 
               NSError *error) 
      { 

       if (!error) 
       { 
        NSLog(@"post success"); 

       } 
      }]; 

는하지만 나는이 정확한 목적을위한 프레임 워크를 썼다

답변

0
 UIImage *image = [[UIImage alloc]initWithData:[[NSUserDefaults standardUserDefaults] objectForKey :@"image_NSdata]]; 
     NSData *imgData = UIImageJPEGRepresentation(image, 1); 
     NSLog(@"Size of Image(bytes):%ld",(unsigned long)[imgData length]); 

     float actualHeight = image.size.height; 
     float actualWidth = image.size.width; 



     NSDictionary * postDictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"equirectangular", [NSNumber numberWithFloat:actualWidth] ,[NSNumber numberWithFloat:actualHeight], [NSNumber numberWithFloat:actualWidth] ,[NSNumber numberWithFloat:actualHeight], @"0",@"0", nil] 
      forKeys:[NSArray arrayWithObjects:@"ProjectionType", @"CroppedAreaImageWidthPixels",@"CroppedAreaImageHeightPixels", @"FullPanoWidthPixels",@"FullPanoHeightPixels", @"CroppedAreaLeftPixels",@"CroppedAreaTopPixels", nil]]; 


     NSError * error = nil; 

     NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:NSJSONWritingPrettyPrinted error:&error]; 
     NSString *resultAsString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 
     NSLog(@"jsonData as string:\n%@ Error:%@", resultAsString,error); 


     NSString *token = [NSString stringWithFormat:@"%@", [FBSDKAccessToken currentAccessToken].tokenString]; 
     NSDictionary *param = @ 
           { 

           @"access_token": token, 
           @"photo":image, 
           @"allow_spherical_photo": [NSNumber numberWithBool:true], 
           @"spherical_metadata":resultAsString 

           }; 

     FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] 
             initWithGraphPath:@"me/photos" 
             parameters:param 
             HTTPMethod:@"post"]; 

     [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, 
               id result, 
               NSError *error) 
      { 

       if (!error) 
       { 
        NSLog(@"post success"); 

       } 
      }]; 
0

360 볼 수있는 일반적인 이미지와 같은 포스트 아니었다 공유 권한이 있다면 다음과 같이 사용하십시오.

[[Facebook360Manager sharedInstance] shareImage:[UIImage imageNamed:@"spherical360.jpg"] 
             userCaption:@"Example caption..." 
            horizontalFOV:360.0 
            sharePreference:FacebookShareManagerPreferenceSphericalImage 
            completionBlock:^(NSError * _Nullable error, NSString * _Nullable postID) { 
            if (error) { 
             NSLog(@"Error: %@",error); 
            }else{ 
             NSLog(@"Shared successfully. Post ID: %@",postID); 
            } 
            }];