iphone FBconnect - publish stream for multiple friend's - iphone

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++;
}
}

Related

Post to Facebook Friend's Wall in iPhone using New Facebook SDK

I want to post some texts and photo to one of my friend's wall using FBDialog.
I have a method like this
- (void)apiDialogFeedFriend:(NSString *)friendID :(NSString *)mImageSTR{
currentAPICall = kDialogFeedFriend;
FBSBJSON *jsonWriter = [FBSBJSON new];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
friendID, #"to",
#"I'm using the Hackbook for iOS app", #"name",
#"Hackbook for iOS.", #"caption",
#"Check out Hackbook for iOS to learn how you can make your iOS apps social using Facebook Platform.", #"description",
#"http://m.facebook.com/apps/hackbookios/", #"link",
#"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png", #"picture",
actionLinksStr, #"actions",
nil];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[delegate facebook] dialog:#"feed"
andParams:params
andDelegate:self];
}
Through these i get call back to dialogCompleteWithUrl method of FBDialogDelegate.
I have implemented this delegate method like this :
- (void)dialogCompleteWithUrl:(NSURL *)url {
if (![url query]) {
return;
}
NSDictionary *params = [self parseURLParams:[url query]];
switch (currentAPICall) {
case kDialogFeedUser:
case kDialogFeedFriend:
{
// Successful posts return a post_id
if ([params valueForKey:#"post_id"]) {
[self showMessage:#"Published feed successfully."];
NSLog(#"Feed post ID: %#", [params valueForKey:#"post_id"]);
}
break;
}
case kDialogRequestsSendToMany:
case kDialogRequestsSendToSelect:
case kDialogRequestsSendToTarget:
{
// Successful requests return the id of the request
// and ids of recipients.
NSMutableArray *recipientIDs = [[NSMutableArray alloc] init];
for (NSString *paramKey in params) {
if ([paramKey hasPrefix:#"to["]) {
[recipientIDs addObject:[params objectForKey:paramKey]];
}
}
if ([params objectForKey:#"request"]){
NSLog(#"Request ID: %#", [params objectForKey:#"request"]);
}
if ([recipientIDs count] > 0) {
[self showMessage:#"Sent request successfully."];
NSLog(#"Recipient ID(s): %#", recipientIDs);
}
break;
}
default:
break;
}
}
Here I get correct value of url as fbconnect://success?post_id=100001402819851_418640698226650.
Now, my problem is that in my friend wall my post is not seen/visible.
Any help would be appreciated.

Post on personal Facebook wall using ios sdk and tag multiple friends at once..?

I am trying to post a message on my wall and wanted to tag multiple users at a time in this post. I tried the various options on the FB post page but couldn't do it. May be I am not doing it right. Any help is appreciated and this is how I am doing it...
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Test 2",#"message",
#"100004311843201,1039844409", #"to",
nil];
[self.appDelegate.facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
I have also tried message_tags but that doesn't seem to work as well.
You would need to use Open Graph to tag people with a message. The me/feed Graph API endpoint doesn't support this.
Mentions Tagging
https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/
Action Tagging:
https://developers.facebook.com/docs/technical-guides/opengraph/publish-action/
You can take a look at the Scrumptious sample app that comes included with the latest Facebook SDK for iOS to see how to do this.
To tag a friend in ur fb status ..you need "facebook id" of your friend by using FBFriendPickerViewController and "place id" using FBPlacePickerViewController. Following code will help you.
NSString *apiPath = nil;
apiPath = #"me/feed";
if(![self.selectedPlaceID isEqualToString:#""]) {
[params setObject:_selectedPlaceID forKey:#"place"];
}
NSString *tag = nil;
if(mSelectedFriends != nil){
for (NSDictionary *user in mSelectedFriends) {
tag = [[NSString alloc] initWithFormat:#"%#",[user objectForKey:#"id"] ];
[tags addObject:tag];
}
NSString *friendIdsSeparation=[tags componentsJoinedByString:#","];
NSString *friendIds = [[NSString alloc] initWithFormat:#"[%#]",friendIdsSeparation ];
[params setObject:friendIds forKey:#"tags"];
}
FBRequest *request = [[[FBRequest alloc] initWithSession:_fbSession graphPath:apiPath parameters:params HTTPMethod:#"POST"] autorelease];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[SVProgressHUD dismiss];
if (error) {
NSLog(#"Error ===== %#",error.description);
if (_delegate != nil) {
[_delegate facebookConnectFail:error requestType:FBRequestTypePostOnWall];
}else{
NSLog(#"Error ===== %#",error.description);
}
}else{
if (_delegate != nil) {
[_delegate faceboookConnectSuccess:self requestType:FBRequestTypePostOnWall];
}
}
If you followed the tutorial on how to setup Open Graph for iOS, you can do something like this if you use the friendsPickerController:
// Create an action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
//Iterate over selected friends
if ([friendPickerController.selection count] > 0) {
NSMutableArray *temp = [NSMutableArray new];
for (id<FBGraphUser> user in self.friendPickerController.selection) {
NSLog(#"Friend selected: %#", user.name);
[temp addObject:[NSString stringWithFormat:#"%#", user.id]];
}
[action setTags:temp];
}
Basically, you can set an array of friend's ids on the "tags" property on an action

App request notification sending failed on facebook

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);
}

Fetching Facebook friends with Graph API

I am trying to retrieve the list of facebook friends of a logged user in an Iphone app.
this is the code I am using
[_facebook requestWithGraphPath:#"me/friends" andDelegate:self];
the result I get is a NSDictionary instance with only an object inside.
Am I doing something wrong?
You parse your DIctionary Data.
Sample code here,
if ([result isKindOfClass:[NSDictionary class]]) {
NSArray *userInfoArray=[result objectForKey:#"data"];
NSMutableArray *userIdArray=[[NSMutableArray alloc ]init];
NSMutableArray *userNameArray=[[NSMutableArray alloc ]init];
for (int indexVal=0; indexVal<[userInfoArray count]; indexVal++) {
NSDictionary *individualUserInfo=[userInfoArray objectAtIndex:indexVal];
[userIdArray addObject:[individualUserInfo objectForKey:#"id"]];
[userNameArray addObject:[individualUserInfo objectForKey:#"name"]];
}
NSLog(#"Frnd Name Array : %# ",userNameArray);
NSLog(#"Id Array : %# ",userIdArray);
}
Here result is the data you received in request:DidLoad delegate method

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).