Post Directly To the app's wall - iphone

i'm trying to post directly from my iOS App to the Facebook application page but with no luck.
i have read this
iOS post to the Facebook app wall
and this
Trying to post directly to an application's wall
but no luck with that.
help please

-(void)postToFacebookAppPage
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"##########...", #"app_id",
#"##########...",#"to",
//#"http://www.facebook.com/pages/AppPageURL", #"link",
//#"icon.png", #"picture",
//#"App Page Name", #"name",
//#"Post to App Facebook Page", #"caption",
#"Do Stuff Facebook page.", #"description",
nil];
AppDelegate *sharedAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[sharedAppDelegate.facebook dialog:#"feed" andParams:params andDelegate:self];
}
Where the numbers #### are for your page.

-(void)postToFacebookAppPage
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"##########...", #"app_id",
//#"http://www.facebook.com/pages/AppPageURL", #"link",
//#"icon.png", #"picture",
//#"App Page Name", #"name",
//#"Post to App Facebook Page", #"caption",
#"Do Stuff Facebook page.", #"description",
nil];
AppDelegate *sharedAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[sharedAppDelegate.facebook dialog:#"pageid/feed" andParams:params andDelegate:self];
}

Related

iOS Post to Facebook publish screen doesn't show after authentication

Alrighty. I have a button (below) where I take some info from an app and I post it to the users FB feed.
It almost never works the first time. Them, it will usually work pretty well after that. What happens is, when I press the button it tells me that I already gave the app permission to use FB (which I would like to only have to see the first time, not every time). Then when I press OK from there it will either go back to the app, or it will go to show me the page where I can actually post to my wall (which is what I want).
Im trying different things to get this to work more consistently. Is there something here that would be causing this behavior?
-(IBAction)fbButton:(id)sender {
if (![facebook isSessionValid]) {
[facebook authorize:permissions];
[permissions release];
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:#"FBAccessTokenKey"]
&& [defaults objectForKey:#"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:#"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:#"FBExpirationDateKey"];
}
//Post to Wall
NSString *poopDollas = [[NSString alloc] initWithFormat:
#"sometext $%#!",dollas.text];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
// The action links to be shown with the post in the feed
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Get Started",#"name",#"http://www.facebook.com/pages/xx/204640386498567",#"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
// Dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"DM", #"name",
poopDollas, #"caption",
#"sometext", #"description",
#"http://www.facebook.com/pages/xx/204640386498567", #"link",
#"http://farm8.staticflickr.com/7185/6999841878_e66a8e00fc_t.jpg", #"picture",
actionLinksStr, #"actions",
nil];
FBDialog *delegate = (FBDialog *)[UIApplication sharedApplication].delegate;
[facebook dialog:#"feed" andParams:params andDelegate:(id <FBDialogDelegate>)delegate];
}
I took out the
[facebook authorize:permissions];
[permissions release];
In that first IF statement and my problems seem to be solved..

iphone: Facebook logout feature is not work in my app [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
iphone: facebook logout feature does not working
i am implementing FB integration through FBConnect
It is not logout from Fb when i pressed logout button
It only show previous Login..
My code is as follows:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (![[delegate facebook] isSessionValid]) {
} else {
[self showLoggedIn];
}
}
- (IBAction)postMessageToWall:(id)sender {
currentAPICall = kDialogFeedUser;
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"TaxSmart Hello.",#"name",#"http://www.google.com",#"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
UIImage *img=[UIImage imageNamed:#"tick.png"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Piyush here.", #"name",
#"This is Great App.", #"caption",
#"FuNNNN.", #"description",
#"http://www.iTaxsmart.com/", #"link",
img.CIImage, #"picture",
actionLinksStr, #"actions",
nil];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[delegate facebook] dialog:#"feed"
andParams:params
andDelegate:self];
}
when you click on logout button call bellow method its work but just check your userdefault key..
- (void)fbDidLogout
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[facebook invalidateSession];
[defaults removeObjectForKey:#"FBAccessTokenKey"];
[defaults removeObjectForKey:#"FBExpirationDateKey"];
[defaults synchronize];
}
hope,this help you.....
:)

Retrive a friend's profile image after loging in

I'm looking for idea on how to use the Facebook connection. I am able to used the Facebook connect on button click, to access the Facebook. The method I wrote:
-(void)login
{
NSMutableDictionary *params=[NSMutableDictionary dictionary];
[params setValue:apiString forKey:#"client_id"];
[_facebook setSessionDelegate:self];
[_facebook dialog:#"oauth" andParams:params andDelegate:self];
}
-(void)fbDidLogin
{enter code here
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: #"4", #"uids", #"name", #"fields", nil];
[_facebook requestWithMethodName: #"users.getInfo" andParams: params andHttpMethod: #"GET" andDelegate: self];
[_facebook requestWithGraphPath:#"me/friends" andDelegate:self];
}
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
NSLog(#"received response");
}
- (void)request:(FBRequest *)request didLoad:(id)result// This method i am using to access all friends name and id after loging.
{
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
NSLog(#"%#" ,result);
}
Now my requirement is that with a friend's name I need to access their profile imag.
How can I get a friend's profile image?
I am using the JSON to access Facebook connect.
"/userid/picture" see also https://developers.facebook.com/docs/reference/api/user/

how to login some other user on facebook in your app?

i am publishing some story on the user's facebook wall in my app. its working fine but i wanna know if some other user wanna login in my app with other facebook account how can he do that. i mean how can i logout an existing user and allow other user to login. my code in AppDelegate is:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
facebook = [[Facebook alloc] initWithAppId:#"app_id"];
NSArray* permissions = [[NSArray arrayWithObjects:
#"publish_stream", nil] retain];
[facebook authorize:permissions delegate:self];
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
and my code in DetailViewController is:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
[sTitle stringByReplacingOccurrencesOfString:#"\"" withString:#"\\\""], #"name",
[sSummary stringByReplacingOccurrencesOfString:#"\"" withString:#"\\\""], #"description",
[sLink stringByReplacingOccurrencesOfString:#"\"" withString:#"\\\""], #"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"XXX", #"api_key",
#"Share on Facebook", #"user_message_prompt",
attachmentStr, #"attachment",
nil];
[appDelegate.facebook dialog:#"stream.publish" andParams:params andDelegate:self];
once app is installed it asks for username and password for facebook. and then it publishes stories to only that user. what about if i wanna change user in my app. where should i write
[facebook logout:self];
You'll need to provide the options for login/ logout. This post will help you how to do it.

iPhone : Cannot launch facebook dialog from alert view

The facebook dialog is not launching from alert view handler.
But facebook dialog launches OK from button.
The code of launching facebook dialog is following
- (void) share_on_facebook
{
_facebook = [[Facebook alloc] initWithAppId:kAppId];
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];
}
The handler of alert view is button click
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
[self share_on_facebook];
}
The facebook dialog is not launched but when I call share_on_facebook from ordinary button click handler the dialog opens successfully.
Please help to figure out the problem.
[self performSelectorOnMainThread:#selector(share_on_facebook)]; should do the trick