Posting from my app in Facebook - objective-c

I would like to update my iOS app to take advantage of iOS 6 Facebook integration. Currently I use the Facebook dialogue. I like the way I can present the dialogue to the user and when it posts it has my app icon and the small tag saying "via my app name" which links to my app.
With the iOS 6 Facebook integration it says "via iOS" and a link to Apple's Website. Is there a way to achieve the same type of result using iOS 6's Facebook integration?
current code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"1234567890", #"app_id",
#"http://www.mywebsite.com/page5/page5.html", #"link",
picLink, #"picture",
countDownName, #"name",
#"My app name", #"caption",
#"For the iPhone and iPod Touch", #"description",
theMessage, #"message",
theFriendID, #"to",
#"Share on Facebook", #"user_message_prompt",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
my iOS 6 code (taken from Facebook's sample code)
BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self
initialText:initialText
image: [UIImage imageNamed: #"myImage.png"]
url:url
handler:nil];
if (!displayedNativeDialog) {
[self performPublishAction:^{
// otherwise fall back on a request for permissions and a direct post
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
self.buttonPostStatus.enabled = YES;
}];
self.buttonPostStatus.enabled = NO;
}];

A quick google search showed the following tutorial: http://www.techotopia.com/index.php/IPhone_iOS_6_Facebook_and_Twitter_Integration_using_SLRequest#Facebook_Integration_using_SLRequest
That seems to be a good tutorial to do what you're looking for.

Please try using custom Facebook compose view provided here.

Related

Facebook feed post not seen by public - ios sdk

I'm using the facebook ios sdk 3.1. In ios 6 the integration has no issues since it uses the native dialog. In ios 5.1, I implemented a fallback to use the feed dialog. The post shows up in user's timeline but doesn't appear in friend's newsfeed. I've tweaked the setting of the facebook app to 'public' but problem still exist.
- (void) publishUsingFeedDialog {
if (_facebook == nil) {
_facebook = [[Facebook alloc]
initWithAppId:FBSession.activeSession.appID
andDelegate:nil];
// Store the Facebook session information
_facebook.accessToken = FBSession.activeSession.accessToken;
_facebook.expirationDate = FBSession.activeSession.expirationDate;
}
// #"Facebook SDK for iOS", #"name",
// #"Build great social apps and get more installs.", #"caption",
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My test with app", #"name",
[self getDescription], #"description",
#"http://www.test.com", #"link",
#"http://www.test.com/logo.gif", #"picture",
nil];
// Invoke the dialog
[_facebook dialog:#"feed" andParams:params andDelegate:(id)self];
}
Thanks
I realized that I didn't include any caption information: #"my caption", #"caption". Even though I can still post without any problems, but facebook algorithm will sometimes hide it from public.

Invite friends with new Facebook api

I've just updated Facebook framework and old code for invite friends does't work(Now there is no Facebook class object.). I used the following code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"1", #"frictionless",
#"My message", #"message",
#"Notification", #"notification_text",nil];
[self.facebook dialog:#"apprequests" andParams:params andDelegate:self];
Is it possible to show the same dialog on the latest framework?
Yes it is. The sample iOS game, Friend Smash (https://github.com/fbsamples/ios-friend-smash), uses this technique. The equivalent code is here:
https://github.com/fbsamples/ios-friend-smash/blob/master/friendsmash/friendSmasher/Game/GameController_FacebookIntegration.cpp#L365

How to get share dialog box with parse.com and facebook 3.0 sdk

I can't seem to find information on how to open share dialog box with parse sdk which includes fb 3.0. I am able to login with facebook and actually found a way to post with out the dialog box but still would like to have the dialog box so that people can add comments and it comes out with the image on facebook. This is what i have so far.
#"publish_stream",#"publish_actions" allows me to publish with out the dialog box
logInController.facebookPermissions = [NSArray arrayWithObjects:#"user_about_me",#"friends_about_me",#"publish_stream",#"publish_actions", nil];
this is to publish
PF_FBRequest *request = [PF_FBRequest requestForPostStatusUpdate:[self.Excerpt objectForKey:#"text"]];
[request startWithCompletionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error){
NSLog(#"error %#",error);
}];
I found the code to open the dialog box from facebook website but i am not sure how to get an instance of the PF_Facebook object so i can open the dialog box. I can try to do
PF_Facebook *fb = [[PF_Facebook alloc]initWithAppId:<#(NSString *)#> andDelegate:<#(id<PF_FBSessionDelegate>)#>;
but that doesn't seem to be right because i already initialize this in the appdelegate
//Update
I am able to get the dialog box using this code
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Facebook SDK for iOS", #"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];
//publishes text on facebook
PF_FBSession *session = [PFFacebookUtils session];
PF_Facebook *fb = [[PF_Facebook alloc]initWithAppId:session.appID andDelegate:nil];
[fb dialog:#"feed" andParams:params andDelegate:self];
But the problem is that the person gets the login page in the dialog box even though he is authenticated already in the app
Any suggestions would be greatly appreciated!
Thank You!
To set up a PF_Facebook object you need to also provide the access token and expiration date information as below:
PF_FBSession *session = [PFFacebookUtils session];
PF_Facebook *facebook = [[PF_Facebook alloc] initWithAppId:session.appID
andDelegate:nil];
// Store the Facebook session information
facebook.accessToken = session.accessToken;
facebook.expirationDate = session.expirationDate;
Rather than creating a new session, you can just use the "facebook" class method to get a configured PF_Facebook object
PF_Facebook *facebook = [PFFacebookUtils facebook];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Check out this great app", #"message", nil]:
[facebook dialog:#"apprequests" andParams:parameters andDelegate:nil];

Post to Friend's Wall with iOS Facebook SDK

Is it possible to use the iOS Facebook SDK's dialog method to post to the active user's friends' walls? That is, assuming the correct permissions have been granted?
Using the dialog method, with "feed" as the action, only seems to allow me to post to the user's stream, not to anyone elses. What am I missing?
[facebook dialog:"feed" andParams:... andDelegate:self]
The params only specify the content of the post; there doesn't seem to be any way to specify the profile I want to post to.
Just use the following code:
[facebook requestWithGraphPath:#"[IdOfFriend]/feed" andParams:... andHttpMethod:#"POST" andDelegate:self];
post on friends wall through graph path no more works
your feed action works.. have params like
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Checkout my APP_NAME", #"name",
#"Come visit my APP_NAME", #"caption",
[NSString stringWithFormat:#"I just joined APP_NAME Can you?"], #"description",
#"http://www.friendsmash.com/images/logo_large.jpg", #"picture",
#"FRIEND'S_FB_USER_ID", #"to",
// Add the link param for Deep Linking
[NSString stringWithFormat:#"https://YOUR_WEB_LINK.com/"], #"link",
nil];
Cheers...!

Broken (grey) thumbnails in Facebook mobile feed?

I have an iOS app that posts to users FB feeds with a link, description, and image.
If I check posts that have been made through my app in a full sized browser, I can see that everything, including the thumbnail is showing as expected.
The problem is if I open the FB feed from a mobile browser or the FB iOS app, I get grey boxes instead of thumbnails.
I have tried this multiple times and I get the grey box in mobile pages every single time and all of the Facebook debug data for the link checks out as far as I can see.
The following is the objective-c code that posts the Feed to FB.
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:self.captionTextView.text forKey:#"message"];
[params setObject:[NSString stringWithFormat:#"%#'s photo on Wander", [appDelegate.prefs valueForKey:#"firstName"]] forKey:#"name"];
[params setObject:shortUrl forKey:#"link"];
NSString *imageURL = [NSString stringWithFormat:#"http://%#/mobile/photo.php?p=%#", appDelegate.apiHost, photoParams];
[params setObject:imageURL forKey:#"picture"];
[params setObject:[NSString stringWithFormat:#"%#, %#", [appDelegate.prefs valueForKey:#"cityName"], [appDelegate.prefs valueForKey:#"countryName"]] forKey:#"caption"];
[params setObject:[NSString stringWithFormat:#"I'm using Wander to explore %# with %# as a local guide!", [matchData valueForKey:#"cityName"], [matchData valueForKey:#"firstName"]] forKey:#"description"];
[appDelegate.facebook requestWithGraphPath:[NSString stringWithFormat:#"%#/feed", fbId] andParams:params andHttpMethod:#"POST" andDelegate:self];
[params release];
This is the test URL: http://maruta.wanderwith.us/viewPhoto/index/My0zNA (this might disappear because it's on a development server and I regularly clear data, I'll try my best to keep it live until this gets resolved)
Am I missing something?
I ran into the same situation. Turns out it was the question mark in your URL. Facebook passes your image URL through their own proxy. If your URL contains "?", then it doesn't work through the mobile feed somehow.
Your server expects url in this format: http://hostname/mobile/photo.php?p=1234567889. If you change this to this format: http://hostname/mobile/photo/1234567889, then Facebook will be happy. try mod rewrite if you are using apache.