Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }];
- -(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];
- }];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement