試圖讓我的應用使用SLRequest發佈到Facebook,但遇到問題。權限被批准罰款,它只是不會發布。在iOS 6中使用SLRequest發佈到Facebook
-(void)requestPermissions
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
__block ACAccount *facebookAccount = nil;
ACAccountType *facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{
ACFacebookAppIdKey: @"MYAPPID",
ACFacebookPermissionsKey: @[@"email", @"user_about_me", @"user_likes"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};
[accountStore requestAccessToAccountsWithType:facebookAccountType
options:options completion:^(BOOL granted, NSError *e)
{
if (granted) {
NSDictionary *options2 = @{
ACFacebookAppIdKey: @"MYAPPID",
ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options2 completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject]; }
else {
NSLog(@"Access denied 2");
NSLog(@"%@", [error description]);
}
}];
} else {
NSLog(@"Error: %@", [e description]);
NSLog(@"Access denied");
}
}];
NSDictionary *parameters = @{@"message": @"This is a test"};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:parameters];
NSLog(@"AnythingHere?");
feedRequest.account = facebookAccount;
[feedRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
// Handle response
NSLog(@"%@%@%@", error, responseData, urlResponse);
}];
}
對於最後一部分,日誌中的錯誤返回null。對此有何想法?
UPDATE:所以問題是HTTP響應回來爲400
我有同樣的問題,但只有與特定的Facebook帳戶。如果您找到解決方案,請更新 – zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz