Issue with Facebook feed dialog - objective-c

I'm trying implement a Facebook dialog feed, but it doesn't show anything. I have followed :
Post to user's Facebook wall with iPhone using latest FBConnect SDK
and:
http://developers.facebook.com/docs/reference/dialogs/feed/
Here is my code:
-(void) facebookPost{
NSString *kAppId = [[NSString alloc] initWithString:#"383032031757454"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
#"http://developers.facebook.com/docs/reference/dialogs/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Facebook Dialogs", #"name",
#"Reference Documentation", #"caption",
#"Using Dialogs to interact with users.", #"description",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
}
Many thanks for your help.
Froi

i think u have to set accessToken like below
[params setObject:facebook.accessToken forKey:#"access_token"];
[facebook dialog:#"feed" andParams:params andDelegate:self];

Related

How to set default String from native ios app to facebook page from iphone app using dialog

below is my code
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"MyTestAPP", #"name",
#"http://myserver.com/", #"link",
#"My Post!", #"caption",
#"ValuedCommunity", #"description",
myMessage, #"message",
nil];
// Publish.
[facebook dialog:#"feed" andParams:params andDelegate:self];
Now with this code when I click on publish button I get this
I have tried graph api using the below code but it gave me an error msg of "facebookerrdomain error 10000".
[facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
Now What I want to do is, want to set "myMessage" text instead of Say Something about this.
Is it possible to do so??
If yes then how can I achieve it.
Please Advice
Thanks
Everything is possible. Use requestWithGraphPath:andParams:andHttpMethod:andDelegate: method and set permission as publish_stream, then you will get message.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
yourMessage,#"message",nil];
NSString *user_selected = [NSString stringWithFormat:#"me/feed"];
[facebook requestWithGraphPath:user_selected andParams:params andHttpMethod:#"POST" andDelegate:self];
Hi Every1 I was Trying to solve this from past 2 days And How I solved
add One more parameter named access_token in NSMutableDictionary's param object like this
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Ahha", #"name",
#"http://vctestserver.com/", #"link",
#"VCAHHA", #"caption",
#"ValuedCommunity", #"description",
storyTwtFB, #"message",
accessToken,#"access_token",
nil];
[facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
Where I got accessToken's Value from delegate mathod [facebook accessToken]. and storyTwtb is my application's String that I wanted to post on facebook.

how to Uploading image with text to facebook using FBRequestConnection?

I am trying to upload the text with image using FBRequestConnection like as follow but I am only able to upload text,not the image.
But when I am giving any image link in place of img1(image) then I am able to see the image on the facebook wall.
UIImage *img1 = [UIImage imageNamed:#"Default#2x.png"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"https://developers.facebook.com/ios", #"link",
img1, #"picture",
#"Facebook SDK for iOS", #"name",
#"build apps.", #"caption",
#"imagae description.", #"description",
nil];
[params setObject:#"post message" forKey:#"message"];
[FBRequestConnection
startWithGraphPath:#"me/feed"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
alertText = [NSString stringWithFormat:
#"error: domain = %#, code = %d",
error.domain, error.code];
} else {
alertText = #"Posted successfully.";
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:#"Result"
message:alertText
delegate:self
cancelButtonTitle:#"OK!"
otherButtonTitles:nil]
show];
}];
I have taken the two permission #"publish_actions",#"user_photos"
Please let me know where I am wrong in this code.
Check out my answer in the IOS Facebook SDK 3 upload image with message
It is the similar way which you required. Just add some more parameters as per your requirements.
Change #"picture" to #"source".
If you are using new Facebook 3.1 SDK you can do it simpler:
FBRequest *req = [FBRequest requestForUploadPhoto:img1];
[req.parameters addEntriesFromDictionary:[NSMutableDictionary dictionaryWithObjectsAndKeys:#"post message", #"message", nil]];
FBRequestConnection *con = [[FBRequestConnection alloc] init];
[con addRequest:req completionHandler....

IOS Fb wall post method not working

I am using following code. It takes me to FB Dialog box where I authorize the app and after authorizing app it takes me back to my applicaiton. However It NEVER post anything on the wall.
Any ideas what is wrong?
- (void) login
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.facebook = [[Facebook alloc] initWithAppId:#"MY_APP_ID" andDelegate:self];
NSArray* permissions = [NSArray arrayWithObjects:#"publish_stream", nil];
[appDelegate.facebook authorize:permissions];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#".", #"name",
#".", #"caption",
nil];
/*
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#".", #"name",
#"Build great social apps and get more installs.", #"caption",
#"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", #"description",
#"https://developers.facebook.com/ios", #"link",
#"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png", #"picture",
nil];
*/
// Invoke the dialog
[appDelegate.facebook dialog:#"feed" andParams:params andDelegate:self];
}
You should do it like this:
graphPath = #"me/feed";
[params setObject:#"link" forKey:#"type"];
[params setObject:pict forKey:#"picture"];
[params setObject:self.url forKey:#"link"];
[params setObject:self.message forKey:#"message"];
[params setObject:self.urlName forKey:#"name"];
[params setObject:self.caption forKey:#"caption"];
[params setObject:self.urlDescription forKey:#"description"];
[appDelegate.facebook requestWithGraphPath:graphPath andParams:params andHttpMethod:#"POST" andDelegate:self];

Posting Screenshot of GameOver to FaceBook via Cocos2d

I have searched a lot of forums and thread about posting screenshot on facebook. I have found the functon which is to be added in CCDirector which creates Screenshot. I have also seen the method which post the screenshot on facebook in an album or wall. But that is not working for me.
UIImage *tempImage = [[CCDirector sharedDirector] screenshotUIImage];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
tempImage,#"message",
nil];
[facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
screenshotUIImage is the function that makes screenshot and it is working alright.
requestWithGraphPath does not do any thing for me. I have used different keywords in params like "tempImage, #"source"," and "tempImage, #"image"," but nothing happens.
However posting text on wall, like high score with predefined image link is working alright.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
imageSrc, #"picture",
serverLink, #"link",
postName, #"name",
customMessage, #"caption",
nil];
// Post on Facebook.
[_facebook dialog:#"feed" andParams:params andDelegate:self];
Can any one guide me through how to do the picture posting?
In your params, you can try specifying a UIImage for the the key "picture":
UIImage *tempImage = [[CCDirector sharedDirector] screenshotUIImage];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:myCaption forKey:#"caption"];
[params setObject:myMessage forKey:#"message"];
...
// UIImage object goes here
[params setObject:tempImage forKey:#"picture"];
[facebook requestWithGraphPath:#"me/photos" andParams:params andHttpMethod:#"POST" andDelegate:self];

Facebook iPhone SDK - automatically PublishSteam (bypass Post to wall dialog)

Trying to implement facebook wall post on the iphone app I'm working on.
How can I bypass the "Post to Your Wall" dialog box and just submit straight?
Basically I'm just trying to post a url and I don't really want to allow people to see that "Write something" textbox.
Here is the code that I have so far (from the sample app).
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"a long run", #"name",
#"The Facebook Running app", #"caption",
#"it is fun", #"description",
#"http://itsti.me/", #"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Share on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
nil];
[_facebook dialog:#"feed"
andParams:params
andDelegate:self];
Thank you,
Tee
Just use one of the - (FBRequest*)requestWith... instance methods of the Facebook class.
Simple wall post using the old REST API:
NSString *facebookStatusMessage = #"facebookStatusMessage";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
facebookStatusMessage, #"status",
nil];
FBRequest *request = [_facebook requestWithMethodName:#"status.set" andParams:params andHttpMethod:#"POST" andDelegate:self];
It's better to use the Facebook Graph API with - (FBRequest*)requestWithGraphPath: as the REST API will get deprecated.
Then also implement some of the FBRequestDelegate protocol:
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
}
- (void)request:(FBRequest *)request didLoad:(id)result {
// result may be a dictionary, an array, a string, or a number,
// depending on the format of the API response
}