App request notification sending failed on facebook - iphone

I am new in Iphone and stuck here in facebook application , In fact I am getting list of all of my facebook friends with their id's in my TableView. When I tab on table view I want to send notification to my friend, dialoge is showing , when i press the send button, facebook dialoge disappear, and my friend don't receive the notification. Can you help me please. Here is my code,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* kAppId = #"317060778330475";
Facebook *faceBook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self];
NSDictionary *dic = [facebookInfoArray objectAtIndex:indexPath.row];
NSString *friendId = [dic valueForKey:#"id"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Hi check my application, please!", #"message",
friendId, #"to",
nil];
[faceBook dialog:#"apprequests" andParams:params andDelegate:self];
}
#pragma mark - Facebook Delegates
- (void)dialogDidComplete:(FBDialog *)dialog {
NSLog(#"App Request Sent!");
}
- (void)dialogCompleteWithUrl:(NSURL *)url {
NSLog(#"Urls is :%#",url);
}

Related

how we add delay in between loop of posting facebook friend status through dialog ?

i used to dialog for posting friend wall.
here self.fbFriendsInvitedid is array of my friends id.i want delay of dilog open.because if array elements are greter then app crashed..what should i do?
Facebook *fb = [((AppDelegate*)[[UIApplication sharedApplication] delegate]) fbInstance];
NSLog(#"%#",self.fbFriendsInvited);
NSLog(#"%#",self.fbFriendsInvitedid);
for (int i=0; i<self.fbFriendsInvitedid.count; i++) {
NSObject *obj=[self.fbFriendsInvitedid objectAtIndex:i];
NSLog(#"%#",obj);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
obj,#"to",#"Invite Me", #"name", #"available for iOS apps in Facebook Platform.", #"caption", #"Check out 'Invite Me' for iOS & be my friend here",#"description",#"http://www.inviteme.com",#"link",#"http://www.facebookmobileweb.com/inviteme/img/facebook_icon_large.png", #"picture",nil];
[fb dialog:#"feed" andParams:params andDelegate:self];
please help.!!
you can put your code in some method and call it after the delay like below :
[self performSelector:#selector(onClickPost) withObject:nil afterDelay:0.5];

Facebook friend list

I am working on application where I want to access user friends list by login into facebook application. I am using xcode 4.2 ios 5 framework. I have gone through many tutorial but didn't find proper solution. please help me out.
- (void)getFriendsResponse {
FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:#"me/friends" withGetVars:nil];// me/feed
//parse our json
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary * facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];
//init array
NSMutableArray * feed = (NSMutableArray *) [facebook_response objectForKey:#"data"];
NSMutableArray *recentFriends = [[NSMutableArray alloc] init];
//adding values to array
for (NSDictionary *d in feed) {
NSLog(#"see Dicitonary :%#",d );
facebook = [[Facebook alloc]initWithFacebookDictionary:d ];
[recentFriends addObject:facebook];
NSLog(#"Postsss :->>>%#",[facebook sender]);
[facebook release];
}
friends = recentFriends;
[self.tableView reloadData];
}
use facebook graph api. To get a list of their friend lists, you need read_friendlists extended permission. Graph Api reference and permissions

iphone FBconnect - publish stream for multiple friend's

currently i m working on iphone application(facebook connect),
Is it possible to post the messages to MULTIPLE friends walls? Currently i am able to send message on single friend wall using "PUBLISH STREAM".
SO Using publish stream is it possible to send message on multiple friend's wall at a time ??
There is no such functionality I guess. But you can do it.
Check the example:
These are Fb delegate methods add to the class.
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
NSLog(#"received response");
};
Getting friends UIDs: after logged in get the friends details and store the friends UIds in an array 'uids'
- (void)request:(FBRequest *)request didLoad:(id)result {
if([result isKindOfClass:[NSDictionary class]]) {
NSLog(#"dictionary");
result=[result objectForKey:#"data"];
if ([result isKindOfClass:[NSArray class]]) {
for(int i=0;i<[result count];i++){
NSDictionary *result2=[result objectAtIndex:i];
NSString *result1=[result2 objectForKey:#"id"];
NSLog(#"uid:%#",result1);
[uids addObject:result1];
}
}
}
}
- (void)request:(FBRequest *)request didLoadRawResponse:(NSData *)data
{
NSString *dataresponse=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(#"data is :%#",dataresponse);
}
Posting To All FB Friends:
Itterate the post till [uids count];
- (void)conncetToFriends:(id)sender {
static int ij=0;
NSMutableDictionary* params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:appId, #"api_key", #"Happy Holi", #"message", #"http://www.holifestival.org/holi-festival.html", #"link", #"http://www.onthegotours.com/blog/wp-content/uploads/2010/08/Holi-Festival.png", #"picture", #"Wanna Kno abt HOLI.. Check this...", #"name", #"Wish u 'n' Ur Family, a Colourful day...", #"description", nil];
NSLog(#"uid count:%i",[uids count]);
for(int i=0;i<[uids count];i++) {
NSString *path=[[NSString alloc]initWithFormat:#"%#/feed",[uids objectAtIndex:i]];
NSLog(#"i value:%i",ij);
//[facebook dialog:#"me/feed" andParams:params1 andDelegate:self];
[facebook requestWithGraphPath:path andParams:params1 andHttpMethod:#"POST" andDelegate:self];
ij++;
}
}

facebookErrDomain error 10000 when calling graph api Facebook ios

I'm struggling with the graph api for a few days now and I can't seem to get any further.
In my appdelegate i've placed the following code within the didFinishLaunching
facebook = [[Facebook alloc] initWithAppId:#"cut-app-id-out"];
NSArray* permissions = [[NSArray arrayWithObjects:
#"email", #"user_location", #"user_events", #"user_checkins", #"read_stream", nil] retain];
[facebook authorize:permissions delegate:self];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"test message from stackoverflow", #"message",
nil];
[facebook requestWithGraphPath:#"/me/feed" andParams:params andDelegate:self];
as you can see i'm trying to get the users feed out. I use the following code to place the data into a proper dictionary.
- (void)request:(FBRequest*)request didLoad:(id)result
{
if ([result isKindOfClass:[NSDictionary class]]) {
NSLog(#"count : %d ", [result count]);
NSArray* resultArray = [result allObjects];
NSLog(#"count : %d ", [result count]);
result = [resultArray objectAtIndex:0];
NSLog(#"count : %d ", [result count]);
result = [result objectAtIndex:0];
}
}
But the didFailWithError: function gives me the following error:
The operation couldn’t be completed. (facebookErrDomain error 10000.)
I've place the FBRequestDelegate in my interface file as following:
#interface TabbedCalculationAppDelegate : NSObject
<FBRequestDelegate>{
Is there something what i'm missing?
There's a lot more needed to handle Facebook responses, especially after authorization. You're not going to be able to make calls against the Facebook API immediately after the authorize method. Please see their sample code which shows how to respond to the various events which you will need to do, most importantly the fbDidLogin and fbDidNotLogin ones. Only once you have a successful login should you access the Graph API.
In addition, it looks like you're trying to post a message with the Graph API. Unfortunately that's not the way to do it and a call like [facebook requestWithGraphPath:#"me/feed" andDelegate:self]; is meant for read-only use. Again, look at the above link for an example of how to use the publish_stream permission (their code has a publishStream example method).

To display permission page in facebook of iphone

I am new to iphone development, i want to display the permission page after logging facebook.
buttonIndex is the index of my actionsheets.
if(buttonIndex == 1)
{
session = [FBSession sessionForApplication:#"My App key" secret:#"My Key" delegate:self];
FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:session] autorelease];
[dialog show];
}
by using those code successfully loggin to facebook, but i want to permission page to display,
so i can use,
- (void)session:(FBSession*)session didLogin:(FBUID)uid
{
NSLog(#"User with id %lld logged in.", uid);
FBPermissionDialog* dialog1 = [[[FBPermissionDialog alloc] init] autorelease];
dialog1.delegate = self;
dialog1.permission = #"uid";
[dialog1 show];
}
But its not working. Where can i put that code.
And I want to share my content after the permission allowed.
If i logout the facebook, it goes to the browser but i want to return my application after logout,
Please help me out, guide me plz.
I would change this dialog1.permission = #"uid"; to something like this
dialog1.permission = #"publish_stream";. Because you want to publish your content to the users stream, right?
- (void)session:(FBSession*)session didLogin:(FBUID)uid
After loggin in I would first check if you might already have the permission to publish to the user's stream, by creating a FBRequest
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: #"publish_stream", #"ext_perm", nil];
[[FBRequest requestWithDelegate:self] call:#"facebook.users.hasAppPermission" params:params];
The result you can evaluate here
- (void)request:(FBRequest*)request didLoad:(id)result
e.g. like this
if ([request.method isEqualToString:#"facebook.users.hasAppPermission"])
{
NSString *success = result;
if ([success isEqualToString:#"1"])
{
NSLog(#"User has app permission");
// publish content now
...
}
else
{ // else ask for permission, opening permission dialog
...
}
I highly recommend this guy's tutorial, Brandon Treb, on integrating Facebook. He does a very thorough presentation and takes you line-by-line, so if it does not work, its a typo on your part. His tutorial got me up and running in less than two hours.
http://brandontreb.com/