gpt4 book ai didi

ios - 将视频发布到 facebook 时,必须使用事件访问 token 来查询有关当前用户错误的信息

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

这是我将视频发布到 Facebook 的代码:

ACAccountStore *accountStore = [[ACAccountStore alloc]init];

NSArray * p = [NSArray arrayWithObjects:@"email",@"basic_info", nil];

NSDictionary * dict=[NSDictionary dictionaryWithObjectsAndKeys:@"xxx",ACFacebookAppIdKey,p,ACFacebookPermissionsKey,ACFacebookAudienceEveryone,ACFacebookAudienceKey, nil];

NSDictionary *options = @{
ACFacebookAppIdKey: @"xxx",
ACFacebookPermissionsKey: @[@"publish_actions",@"publish_stream, " ],
ACFacebookAudienceKey: ACFacebookAudienceFriends,
};
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
NSLog(@"blablalba");
//do nothing here.
if (granted) {
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"posting to fb..");


NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSURL *videoPathURL = [defaults URLForKey:@"vidURL"];

// NSURL *videoPathURL = [[NSURL alloc]initFileURLWithPath:videoPath isDirectory:NO];
// NSData *videoData = [NSData dataWithContentsOfFile:videoPath];
NSData *videoData = [NSData dataWithContentsOfFile:[videoPathURL path]];

NSString *status = @"One step closer.";
NSDictionary *params = @{@"title":status, @"description":status};

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:url
parameters:params];

[request addMultipartData:videoData
withName:@"source"
type:@"video/quicktime"
filename:[videoPathURL absoluteString]];

[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (error) {
NSLog(@"error: %@", error);
}
NSLog(@"httpresponse: %@", urlResponse);
}];
}
}];
}

}];

但是它回来了:

"OAuth \"Facebook Platform\" \"invalid_request\" \"An active access token must be used to query information about the current user.\"";

我不知道我错过了什么。有帮助吗?

最佳答案

您忘记根据请求设置 Facebook 帐户。当您被授予访问权限后,获取帐户:

                           NSArray *accounts = [self.accountStore
accountsWithAccountType:fbAccountType];
self.facebookAccount = [accounts lastObject];

创建请求后,设置帐户

    [request setAccount:self.facebookAccount];

关于ios - 将视频发布到 facebook 时,必须使用事件访问 token 来查询有关当前用户错误的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21668668/

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