gpt4 book ai didi

ios - 发布照片 Facebook iOS

转载 作者:行者123 更新时间:2023-11-29 11:14:22 24 4
gpt4 key购买 nike

我正在尝试将照片上传到 Facebook。我阅读了很多教程和示例,但仍然无法正常工作。很多时候我在这一行得到一个 EXC_BAD_ACCESS:

[_facebook requestWithGraphPath:@"me/photos"
andParams:photosParams
andHttpMethod:@"POST"
andDelegate:self];

其他时候什么也没有出现。我希望用户仅在单击 Facebook 中的“共享图像”时才登录。这就是为什么我没有将委托(delegate)放在 appDelegate 中的原因。下面是我的代码:

if (_facebook != nil)  {
[self fbDidLogin];
}

_publishedImage = img;
_facebook = [[Facebook alloc] initWithAppId:@"235694579858240" andDelegate:self];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"])
{
_facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
_facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}

if (![_facebook isSessionValid])
{
NSArray* permissions = [[NSArray alloc] initWithObjects:
@"offline_access", @"publish_stream", @"publish_actions", @"photo_upload", nil];

[_facebook authorize:permissions];
}

UIImage *imgSource = img;
NSString *strMessage = @"This is the photo caption";
NSMutableDictionary* photosParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
imgSource,@"source",
strMessage,@"message",
nil];

[_facebook requestWithGraphPath:@"me/photos"
andParams:photosParams
andHttpMethod:@"POST"
andDelegate:self];

我的 ViewController 有这些代表:

<UIImagePickerControllerDelegate, UIActionSheetDelegate, UIGestureRecognizerDelegate, MFMailComposeViewControllerDelegate, FBSessionDelegate, FBDialogDelegate, FBRequestDelegate>

编辑:是否有任何插件可以轻松地在 Facebook、G+ 和其他任何地方轻松分享照片?

最佳答案

为什么不使用图表而不是尝试:

      if ([fbAppDelegate.facebook isSessionValid]) {
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"http://hd.ipad-wallpapers.fr/thumbs/wooden_apple_logo_4-t1.jpg // but could also use UIImage", @"picture", nil]; // you don't



[fbAppDelegate.facebook dialog:@"feed" andParams:params andDelegate:self];

}

// this is what I do .....

关于ios - 发布照片 Facebook iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10137151/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com