简体   繁体   中英

Posting to message Facebook from iPhone/iPad

I have a 2-part question about posting messages to Facebook.

1 - I want to pre-populate the message that the user is going to post ie where it says 'Say something about this...' . Is this possible? If so, how? At the moment I have the following setup to produce the post shown below:

    NSMutableDictionary *params = 
    [NSMutableDictionary dictionaryWithObjectsAndKeys:
     @"Steak Expert", @"name",
     @"The must-have iPhone/iPad app for carnivores!", @"caption",
     @"Steak Expert helps you to cook every steak to perfection! With this app in your hand you'll never need to worry about over-cooking or under-cooking a steak again. Perfection every time! ", @"description",
     @"https://m.facebook.com/apps/MY_APP_ID/", @"link",
     @"http://fbrell.com/f8.jpg", @"picture",
     @"Cooking a steak using Steak Expert!",   @"message",   // I thought this would be the required field to populate the text
     nil];
    [facebook dialog:@"feed" andParams:params andDelegate:nil];

在此输入图像描述

2 - The other part of my question is based around the view shown above. Is it possible to automatically post to the wall without the need for this view to appear? Seeing as the user must authorise the app to even connect with Facebook (plus any other specified actions) I can't see it being an issue. If so please could someone advise on how to achieve this?

It is the message field that you are talking about.

message - This field will be ignored on July 12, 2011 The message to prefill the text field that the user will type in. To be compliant with Facebook Platform Policies, your application may only set this field if the user manually generated the content earlier in the workflow. Most applications should not set this.

http://developers.facebook.com/docs/reference/dialogs/feed/

Hope this helps

As @Illep stated, the message field no longer works for the dialog postings.

To answer your second question, you can use the graph API to straight post to a user's wall without showing the dialog box. Take a look at the documentation here . You would use the following code to write the message:

// Set parameters
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:FACEBOOK_ACCESS_TOKEN forKey:@"access_token"];
[params setObject:@"Some preset message" forKey:@"message"];

// Make the request to the graph API
[_facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM