Post string on Facebook wall without showing dialog (iPhone Facebook SDK)
Asked Answered
T

4

5

I have been searching stackoverflow and the internet and did no find a working solution for my intention.

I want to call a method with a string as parameter which is then posted to the facebook wall without showing a dialog. Of course only when a valid session is available.

I tried this:

// post message to facebook pinnwall
- (void)postOnWall:(NSString *)message {

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message",nil];
    [[FBRequest request] call:@"facebook.stream.publish" params:params];
}

Can you guys help me ou with a working method?

Thanks and cheers, doonot

Tildatilde answered 3/3, 2011 at 17:26 Comment(0)
S
9

as Aby said, you have to look at the Graph API to user FB at its full potential.

simple code:

NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];

NSString *wallPost = @"the super wall post";
NSString *linkURL  = @"http://www.supersite.com";
NSString *imgURL   = @"http://www.supersite.com/image.jpg";

[fbArguments setObject:wallPost forKey:@"message"];
[fbArguments setObject:linkURL  forKey:@"link"];
[fbArguments setObject:imgURL   forKey:@"picture"];

[facebook requestWithGraphPath:@"me/feed" 
                    andParams:fbArguments
                andHttpMethod:@"POST"
                  andDelegate:self];
Ship answered 24/5, 2011 at 8:12 Comment(1)
'facebook' which class you're referring for this object?Dictation
L
0

Posted to Facebook Wall u should go through JSON

check out this delgates

- (void)postToWall {

    FBStreamDialog *dialog =[[[FBStreamDialog alloc]init ]autorelease];

    dialog.userMessagePrompt = @"Whats on your Mind about this Articles...";
    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"The Black Sheep: %@ Specials for %@, %@ \",\"href\":\"http://%@/\",\"caption\":\" %@ \",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"http://www.raywenderlich.com/\"}]}",
                         [[BarSplArr objectAtIndex:0]objectForKey:@"barname"],day,date,[[BarSplArr objectAtIndex:0]objectForKey:@"barwebsite"],[[BarSplArr objectAtIndex:0]objectForKey:@"drinkspecials"],[[BarSplArr objectAtIndex:0]objectForKey:@"barimage"]];
    //dialog.actionLinks = @"[{\"text\":\"See My App here!\",\"href\":\"http://www.facebook.com/developers/apps.php?app_id=178257532217623&ret=2/\"}]";
    [dialog show];
}

better u can follow up this way. http://www.raywenderlich.com/77/how-to-post-on-facebook-with-your-iphone-app

superb tutorial

Libnah answered 3/3, 2011 at 18:3 Comment(3)
thanks for the answer. I know this tutorial and also how to post a message using a dialog. But as I mentioned above, i need to post it without showing a dialog...Tildatilde
have you found solution for it.. I want same thing.... and also has another issue stackoverflow.com/questions/5308382Canoewood
Have you got solution ?Clabber
M
0

Have you tried using Graph API..
If you like your application to print on the wall without the user interaction like Dialog box you can use the Graph API.. http://developers.facebook.com/docs/reference/api/post/

Mychael answered 24/3, 2011 at 20:13 Comment(2)
Do you have an example how to send a simple NSString to a users pinwall?Tildatilde
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"How are you", @"message",nil]; [facebook requestWithGraphPath:@"12312302/feed/" andParams:params andHttpMethod:@"POST" andDelegate:self]; where "12312302" is USERID.Mychael
C
0

NOTE : must need "publish_actions" permission and also handle and check accessToken & user is logged in or not.

func postMessageOnFaceBookWall() 
   {
        FBSDKGraphRequest(graphPath: "me/feed", parameters: ["message": "Hello my test post"], httpMethod: "POST").start { (connection, result, error) in
            if error == nil{
                //Handle your response here
           }
            else{
               // error
            }
        }
    }
Clabber answered 4/8, 2017 at 10:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.