Search code examples
iphoneiosxcodefacebookposting

how to post to wall after logging in to FB


i will like to know how to post to my own wall with a string @"123456789" after logging in to FB with this

facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self];

    // Check and retrieve authorization information
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    // Initialize user permissions
    userPermissions = [[NSMutableDictionary alloc] initWithCapacity:1];

    if (![facebook isSessionValid]) {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"publish_stream", 
                                nil];
        [facebook authorize:permissions];
        //[permissions release];
    }

Solution

  • use the following code to feed

      NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       [NSString stringWithFormat:@"YOUR MESSAGE"],
                                       @"message", nil];
        [facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod: @"POST" andDelegate:self];