我浏览了许多链接和教程,但对我不起作用。谁能解释我如何使用 SLRequest 通过 iOS 更改为通过 MyAppName ?逐步或给我一些链接,逐步提供此解决方案。
编辑:我试过了。下面是我的代码可能会有所帮助。
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{
ACFacebookAppIdKey: @"012345678912345",
ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};
[accountStore requestAccessToAccountsWithType:facebookAccountType
options:options completion:^(BOOL granted, NSError *e) {
if (granted) {
NSArray *accounts = [accountStore
accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
}
else
{
// Handle Failure
}
}];
NSDictionary *parameters = @{@"message": @"My first iOS 6 Facebook posting "};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:parameters];
feedRequest.account = self->facebookAccount;
[feedRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
// Handle response
}];
}