FBConnect (IPHONE) , custom publish dialog - iphone

is possible custominzing the FBdialog??, i have already modify the attachment on the dialog when the user wants to publish a post; but i need to make hidden the textfield that the dialog presents...there is a way to access to this property or it's just a webView that load a page from facebook's server?
sorry for my bad english!
thanks in advance

Yes, this is possible. just design your own UI and pass the message to a method containing this code:
NSString *message = #"test message here";
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:message forKey:#"message"];
[params setObject:toID forKey:#"target_id"];
[[FBRequest requestWithDelegate:self] call:#"facebook.Stream.publish" params:params];

Related

Upload image to form in webview, without displaying image picker

I am trying to fill up a web form and submit data without letting the user see the web form itself. I have tried using AFNetworking to do HTTP POST in the background, but I bumped into a problem which I couldn't solve and decided to try something else.
This time, I have a UIWebView which is hidden in the background. I then edit the text in the respective fields using Javascript in the webViewDidFinishLoad:webView as follows:
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:nameField.text forKey:#"name"];
[params setObject:emailField.text forKey:#"email"];
[params setObject:titleField.text forKey:#"title"];
[params setObject:dateString forKey:#"link"];
[params setObject:descriptionTV.text forKey:#"content"];
[params setObject:tag forKey:#"tags"];
[params enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) {
NSLog(#"%# = %#", key, object);
NSString *javascriptString = [NSString stringWithFormat:#"document.getElementById('%#').value = '%#'",key,object];
[webView stringByEvaluatingJavaScriptFromString:javascriptString];
}];
Is there any way I could do the same, but for uploading images/files?
You should use an NSHTTPRequest to POST the image to the form directly. There is no need to use a UIWebView, hidden or otherwise. See this answer for an example of how to implement this. Here is another example of this.

Facebook error getting image on post [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to post photos to facebook iphone fbconnect
I am using FB SDK and getting an error while uploading picture on FB post from my app
in my view did load i have and UIImageView which has an image that i need to be posted on FB the code of the view did load
ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 65)];
ImageView.center = CGPointMake(42, 43);
[View addSubview:ImageView];
and in my method of FB post i did this
UIImage *image = [[UIImage alloc]init];
image = ImageView.image;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:3];
[params setObject:#"LINK_HERE" forKey:#"link"];
// due to this line below, i am getting an error :
// "[UIImage length]: unrecognized selector sent to instance 0x170fa0e0"
// and if use http link instead of image(UIImage) it works, but i want to use my image
[params setObject:image forKey:#"picture"];
[params setObject:#"NAME_HERE" forKey:#"name"];
[params setObject:#"DEC_HERE" forKey:#"description"];
// Invoke the dialog
[self.facebook dialog:#"feed" andParams:params andDelegate:self];
How should i use my UIImage inside this code ... any idea ??
You can only upload URL based images in Facebook dialog method..Images generated within the app or within app bundle cant be uploaded..
To upload those images you have to use graph API
sample code
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
image, #"source",
#"caption desc", #"message",
nil];
[facebook requestWithGraphPath:[NSString stringWithFormat:#"/me/photos?access_token=%#", self.facebook.accessToken]
andParams:params andHttpMethod:#"POST" andDelegate:self];
you can post your image simply like this
UIImage *imgSource = {insert your image here};
NSString *strMessage = #"Images Description";
NSMutableDictionary* photosParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
imgSource,#"source",
strMessage,#"message",
nil];
[self.facebook requestWithGraphPath:#"me/photos"
andParams:photosParams
andHttpMethod:#"POST"
andDelegate:self];
There is a sample app in facebook sdk, please check that.
You can also check out these tutorials:
Facebook Tutorial for iOS: How To Use Facebook’s New Graph API from your iPhone App
Facebook Tutorial for iOS: How To Get a User Profile with Facebook’s New Graph API from your iPhone App
Facebook Tutorial for iOS: How To Post to a User’s Wall, Upload Photos, and Add a Like Button from your iPhone App

iOS: Posting a photo to Facebook and small html as caption

Is it possible to upload an image to photo album and include a small html code as caption with it?
I would like to use the new Graph API to do this.
The following code works, but when I set my text variable to an html code, the caption appears as plain text with all the html tags visible.
Also, in the following code, the its.title is completely ignored when item.text is not null.
if (item.shareType == SHKShareTypeImage && item.image)
{
if (item.title)
NSLog(#"title = %#", item.title);
[params setObject:item.title forKey:#"caption"];
if (item.text) {
NSString *mytext = [NSString stringWithFormat:#"%#\n\nCreated by iPhone app FaceMod: %#", item.text,appURL];
[params setObject:mytext forKey:#"message"];
}
[params setObject:item.image forKey:#"picture"];
// There does not appear to be a way to add the photo
// via the dialog option:
[[SHKFacebook facebook] requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
[self retain]; //must retain, because FBConnect does not retain its delegates. Released in callback.
return YES;
}
My understanding is that the way to post html is to using the "action" key:
NSString *actions = [NSString stringWithFormat:#"{\"name\":\"%# %#\",\"link\":\"%#\"}",
SHKLocalizedString(#"Get"), SHKCONFIG(appName), SHKCONFIG(appURL)];
[params setObject:actions forKey:#"actions"];
But this does not work either and the "action" html code is ignored and does not appear of Facebook.
Thanks for the help.
No. You can't inject HTML into the caption field: Facebook doesn't let you set HTML for values that are displayed in multiple places. Any HTML you submit will be treated as plain text to prevent any HTML injection attacks or visual style changes.

How to post on friend wall using Graph Api in iPhone

i am implementing a facebook application , i have used Graph Api and have successfully logged into facebook and got the friend list with the id in UITableView, now i have one string, how should i post on friend wall, Suppose if i click on any of my friend in UITableView, a message should be post,plz help me
EDIT: Code
NSString *urlString = [NSString stringWithFormat:#"graph.facebook.com/%#/feed",key];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *newRequest = [ASIFormDataRequest requestWithURL:url];
[newRequest setPostValue:#"I'm inviting you to see download the OGC app" forKey:#"message"];
[newRequest setPostValue:fbGraph forKey:#"access_token"];
[newRequest setDidFinishSelector:#selector(postToWallFinished:)];
[newRequest setDelegate:self];
[newRequest startAsynchronous];
i am implementing this in function when clicked on tableview where key is id number for the friends name clicked in and in other function
NSString *responseString = [request responseString];
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *postId = [responseJSON objectForKey:#"id"];
NSLog(#"Post id is: %#", postId);
but i am getting the post id nil plz help me
Are you using the Facebook iOS SDK?
Assuming you are, use requestWithGraphPath e.g.-
[_facebook requestWithGraphPath:#"uid/feed"
andParams:[NSMutableDictionary dictionaryWithObject:#"Post on wall" forKey:#"message"]
andHTTPMethod:#"POST"
andDelegate:self];
Where uid is the user id of the user, naturally.
You'll need to make sure you have the relevant permissions when signing in to Facebook and handle the delegate call back to test for success.
If you're not using the SDK, you can do a similar thing with the Graph API directly, perhaps using your own NSURLConnection's or a third party library like ASIHTTPRequest. The SDK is pretty good and straightforward to use mind.

Facebook graph api with native iPhone application

I want to use the Facebook Graph API in a NATIVE iPhone Application. Has anybody been able to find a way to post images/message on a user's feed?
I have tried all possible ways to post a ‘picture’ (not a URL but a UIImage) on the feed and have been working on this for 2 weeks now.
If you go to facebook.com you can upload a picture from your computer on to the wall. I am using ASIHTTPRequest to work on facebook graph API.
This is the nearest I have gone to posting a picture on the feed. So if I have a ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
The url is https://graph.facebook.com/me/feed
Now to post a picture I do the following:
[request setPostValue:#"My Message" forKey:#"message"];
[request setPostValue:#"somepic.png" forKey:#"picture"];
[request setPostValue:#"Some Name" forKey:#"name"];
[request setPostValue:#"Some description" forKey:#"description];
[request startAsynchronous];
If you try this then everything works fine other than the picture being posted. A blank placeholder for the picture is though show on the feed.
I created a method to help me do this. Hope this is of some help.
Please read the tutorial on how to set up the Facebook SDK.
-(void) updateStatusWithText:(NSString *) fbTitle //Status title
andStoryURL:(NSString *) fbURL //URL for the story
andStory:(NSString *) fbStory //The story
andImage:(NSString *) imageURL //Image to be displayed.
andPrompt:(NSString *) promptString{
NSLog(#"updateStatusWithText");
NSString *attachmentText =[NSString stringWithFormat:#"{\"name\":\"%#\","
"\"href\":\"%#\","
"\"description\":\"%#\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"%#\","
"\"href\":\"%#\"}],"
"\"properties\":{\"Uploaded from an iPhone\":{\"text\":\"AFL Fan\",\"href\":\"Your itunes apstore URL\"}}}", fbTitle, fbURL, fbStory,imageURL,fbURL];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
promptString, #"user_message_prompt",
// actionLinksStr, #"properties",
attachmentText, #"attachment",
nil];
NSLog (#"attachmentText : %#", attachmentText);
[facebook dialog:#"stream.publish"
andParams:params
andDelegate:self];
}