我正试图发布到朋友的墙上,没有任何成功
错误:
错误Domain = com.facebook.sdk代码= 5“操作不能 完成。 (com.facebook.sdk错误5.)“UserInfo = 0xa799fa0 {com.facebook.sdk:HTTPStatusCode = 403, com.facebook.sdk:ParsedJSONResponseKey =( { body = { error = { 代码= 200; message =“(#200)此应用程序禁用向其他用户发布Feed故事”; type = OAuthException; }; }; code = 403; })
LoginViewController中的登录过程:
-(IBAction)facebookButtonPressed:(id)sender {
[facebook authorize:[self permissions]];
}
- (NSArray *)permissions {
static NSArray *pms;
if (pms == nil) {
pms = [[NSArray alloc] initWithObjects: @"user_photos", @"user_location", @"user_birthday",
@"friends_birthday", @"friends_location", @"friends_photos", @"user_relationships",
@"publish_actions", @"publish_stream", nil];
}
return pms;
}
在PostViewController中发布到朋友的时间轴的代码:
- (void)postToFriendWall:(NSString *)userId {
facebook = [[Facebook alloc]initWithAppId:APP_ID andDelegate:self];
if (![facebook isSessionValid]) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[facebook setAccessToken:[defaults objectForKey:FB_ACCESS_TOKEN]];
[facebook setExpirationDate:[defaults objectForKey:FB_EXPIRATION_DATE]];
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *defaultWish = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", DEFAULT_WISH, [defaults objectForKey:FB_USER_ID]]];
NSString *defaultImage = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", DEFAULT_IMAGE, [defaults objectForKey:FB_USER_ID]]];
if (defaultImage == nil && defaultWish == nil) {
[self showAlertViewWithTitle:@"Post wasn't sent" message:@""];
return;
}
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[params setObject:defaultWish forKey:@"message"];
if (![defaultImage isEqualToString:@"none"])
[params setObject:[UIImage imageNamed:defaultImage] forKey:@"picture"];
[facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed", userId] andParams:params andHttpMethod:@"POST" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
}
- (void)fbDidLogin {
}
- (void)fbDidExtendToken:(NSString*)accessToken expiresAt:(NSDate*)expiresAt {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:FB_ACCESS_TOKEN];
[defaults setObject:[facebook expirationDate] forKey:FB_EXPIRATION_DATE];
[defaults synchronize];
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
NSString *errorDescription = [error description];
}
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
}
- (void)fbDidNotLogin:(BOOL)cancelled{
}
- (void)fbDidLogout{
}
- (void)fbSessionInvalidated{
}
- (void)fbDialogLogin:(NSString *)token expirationDate:(NSDate *)expirationDate {
}
- (void)fbDialogNotLogin:(BOOL)cancelled {
}
答案 0 :(得分:1)
截至2013年2月6日,您无法使用该图表方法发布到朋友的时间轴。
请阅读:https://developers.facebook.com/roadmap/completed-changes/
寻找feed Dialog,user mentions tagging或Open Graph Actions作为替代方案。
答案 1 :(得分:0)
我使用此代码并收到错误:
- (void)showFeedDialog {
// Put together the dialog parameters
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
@"MY_APP_ID", @"app_id"
@"feed", @"method"
@"USER_ID", @"to",
@"try", @"caption",
@"https://developers.facebook.com/docs/reference/dialogs/", @"link",
@"try link", @"name",
@"http://fbrell.com/f8.jpg", @"picture",
@"Using%20Dialogs%20to%20interact%20with%20users.", @"description",
@"https://mighty-lowlands-6381.herokuapp.com/", @"redirect_uri",
nil];
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil//[FBSession activeSession]
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or publishing story.
NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(@"User canceled story publishing.");
} else {
// Case C: Dialog shown and the user clicks Cancel or Share
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User clicked the Cancel button
NSLog(@"User canceled story publishing.");
} else {
// User clicked the Share button
NSString *postID = [urlParams valueForKey:@"post_id"];
NSLog(@"Posted story, id: %@", postID);
}
}
}
}];
}