2017-10-27 19 views
0

Theta Camera SDKを使用して360度の画像を撮影しています。FacebookでTheta 360度の写真を投稿する方法

私はこの写真をFacebookに投稿します。これは360 photoです。

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); 
            } 
            }]; 
関連する問題