Reputation: 61
I need to checkin on Facebook, without using the default checkin option that comes with Facebook iOS SDK, because I need to filter the Facebook places, so that user can only checkin using places I filtered. I have tried this using Facebook graph api.
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:accsstoken,@"access_token",@"253651184683030",@"place",@"I m here in this place",@"message",@"30.893075018178,75.821777459326",@"coordinates", nil];
[FBRequestConnection startWithGraphPath:@"/me/checkins"
parameters:dict
HTTPMethod:@"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(@"Error...%@",error);
}];
if anybody know about this, Do let me know ? Any kind of help will be appreciated.
Upvotes: 2
Views: 2275
Reputation: 4817
Here is a working code:
_place.facebookId = place id of location to checkin in
listFriends = a list of friend's id to checkin with
-(void)publishToFacebook:(NSString *)message
{
// Create the parameters dictionary that will keep the data that will be posted.
NSMutableArray *fArray = [NSMutableArray new];
for (RCPerson *person in listFriends)
{
[fArray addObject:person.ID];
}
NSMutableDictionary * params = [NSMutableDictionary new];
if(fArray.count > 0)
{
params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message",[fArray componentsJoinedByString:@","], @"tags", _place.facebookId, @"place", nil];
}
else
{
params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message", _place.facebookId, @"place", nil];
}
NSLog(@"params %@", params);
FBRequest *postRequest = [FBRequest requestWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];
postRequest.session = FBSession.activeSession;
if(![postRequest.session.permissions containsObject:@"publish_stream"])
{
[postRequest.session requestNewPublishPermissions:@[@"publish_stream", @"publish_actions"] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *session, NSError *error) {
[postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"error %@", error.description);
if(error)
{
dispatch_async(dispatch_get_main_queue(), ^(void) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook error" message:[self parseError:error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
});
}
NSLog(@"%@", result);
//[self checkinMe];
}];
}];
}
else
{
[postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"error %@", error.description);
if(error)
{
dispatch_async(dispatch_get_main_queue(), ^(void) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook error" message:[self parseError:error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
});
}
NSLog(@"%@", result);
//[self checkinMe];
}];
}
}
Upvotes: 1
Reputation: 23634
So first off, according to the Facebook API docs, the action you are trying to perform is deprecated.
You can read about it here.
Now, you use /{user-id}/feed, and just add a location ID. Read the docs for this action here.
As for filtering, Not sure how that is a problem. Just filter the list of locations you show the user however you want and make sure to only pass one of those locations as the place
.
Upvotes: 1
Reputation: 20753
Publishing with /checkin
is now deprecated. Check out the documentation - /checkin
You have to use Open Graph Actions to do the same, here is the discussion on same: facebbok sdk Integrate interactive map in a post like Foursquare
Upvotes: 0