我想发布图像到Facebook和Twitter。 我很好的叽叽喳喳,但不使用SLComposeViewController类的Facebook。 随着出添加图像,我能够发布文字和网址进入Facebook的。 问题是,当我使用添加图片我无法张贴此图像和文字,网址。 SLComposeViewController显示当我发送图片,文字和网址。 我有正确的appid,我没有得到任何错误。 但问题仍然存在。 我不知道问题出在哪里。 请帮我。
- (void)performFBRequestUploadForImage{
[self showListOfFaceBookAccountsFromStore];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
NSString *output;
switch (result) {
case SLComposeViewControllerResultCancelled:
output = @"ACtionCancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Post Successfull";
[self dismissViewControllerAnimated:YES completion:nil];
break;
default:
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Face Book Message" message:output delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
};
[mySLComposerSheet addImage:[UIImage imageNamed:@"images4.jpg"]];
[mySLComposerSheet setInitialText:@"I am developer."];
[mySLComposerSheet addURL:[NSURL URLWithString:@"http://stackoverflow.com/"]];
[mySLComposerSheet setCompletionHandler:completionHandler];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
}
- (void)showListOfFaceBookAccountsFromStore
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
if( [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook] )
{
NSDictionary *options = @{
@"ACFacebookAppIdKey" : myAppId,
@"ACFacebookPermissionsKey" : @[@"publish_stream"],
@"ACFacebookAudienceKey" : ACFacebookAudienceFriends};
[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error){
if(granted) {
ACAccount * account = [[accountStore accountsWithAccountType:accountType] lastObject];
NSLog(@"Facebook user: %@",[account username]);
if([account username]==NULL){
[self facebookAlert];
} else {
}
}
else{
NSLog(@"Read permission error: %@", [error localizedDescription]);
}
}];
} else {
[self facebookAlert];
}
}