【问题标题】:Share image to Facebook from iOS/Android using Facebook API in Unity3D使用 Unity3D 中的 Facebook API 将图像从 iOS/Android 共享到 Facebook
【发布时间】:2016-09-06 21:43:06
【问题描述】:

我在我的应用中使用 Facebook SDK 插件进行社交分享。

我可以登录并在用户墙上分享照片。

我想将该图像上传到我从 Facebook 帐户创建的 Facebook 上。是否有 Facebook API 用于在 facebook 页面上共享图像。

请帮忙,例如我的 facebook 页面 Url 是 https://www.facebook.com/demoneptune/ 谢谢。

【问题讨论】:

标签: android ios facebook facebook-graph-api unity3d


【解决方案1】:

您需要一些来自 facebook 的权限,最重要的权限是“publish_actions”。

您需要您要发布到的 Facebook 页面的 page_ID。

然后试试这个:

NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:@"Your own message" forKey:@"message"];
[params setObject:@"facebook_page_id_path_string" forKey:@"place"];

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/feed" parameters:params HTTPMethod:@"POST"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(@"result %@",result);
NSLog(@"error %@",error);
if (!error) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Posted!" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    [alert show];
     double delayInSeconds = 1.0;
     dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
     dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [alert dismissWithClickedButtonIndex:0 animated:YES];
     });
  } else {
      NSString *message = @"There was a problem sharing. Please try again!";
      [[[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
  }
}];

希望这会有所帮助。

【讨论】:

  • 谢谢... "place" 键是什么? (顺便说一句,这是针对 Unity3D,而不是 objC :) 但代码基本相同,谢谢。)
  • 它通常被称为使用 "me/photos""me/feed' 有什么区别?谢谢...
  • 我遇到了同样的要求,并在许多方面工作(publish_stream、me/feed,...)。在developers.facebook.com 中有一个演示图API。在那里我开始了解“我/饲料”。它奏效了,我遵循了@Joe Blow。
  • 好一个@satishA,和我/饲料它最终会出现在用户的“墙上”吗?谢谢。
  • 使用 me/feed 和 page_id,将其发布到该页面。但根据 facebook,如果用户在任何其他用户的墙/页面上发帖,它也会出现在他/她的墙上 @Joe Blow。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多