Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:accsstoken,@"access_token",@"253651184683030",@"place",@"I m here in this place",@"message",@"30.893075018178,75.821777459326",@"coordinates", nil];
  2.  
  3. [FBRequestConnection startWithGraphPath:@"/me/checkins"
  4. parameters:dict
  5. HTTPMethod:@"POST"
  6. completionHandler:^(
  7. FBRequestConnection *connection,
  8. id result,
  9. NSError *error
  10. ) {
  11. NSLog(@"Error...%@",error);
  12.  
  13. }];
  14.  
  15. -(void)publishToFacebook:(NSString *)message
  16. {
  17. // Create the parameters dictionary that will keep the data that will be posted.
  18. NSMutableArray *fArray = [NSMutableArray new];
  19. for (RCPerson *person in listFriends)
  20. {
  21. [fArray addObject:person.ID];
  22. }
  23.  
  24. NSMutableDictionary * params = [NSMutableDictionary new];
  25.  
  26. if(fArray.count > 0)
  27. {
  28. params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message",[fArray componentsJoinedByString:@","], @"tags", _place.facebookId, @"place", nil];
  29.  
  30. }
  31. else
  32. {
  33. params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message", _place.facebookId, @"place", nil];
  34.  
  35. }
  36.  
  37. NSLog(@"params %@", params);
  38. FBRequest *postRequest = [FBRequest requestWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];
  39. postRequest.session = FBSession.activeSession;
  40. if(![postRequest.session.permissions containsObject:@"publish_stream"])
  41. {
  42.  
  43. [postRequest.session requestNewPublishPermissions:@[@"publish_stream", @"publish_actions"] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *session, NSError *error) {
  44. [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
  45. NSLog(@"error %@", error.description);
  46. if(error)
  47. {
  48. dispatch_async(dispatch_get_main_queue(), ^(void) {
  49. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook error" message:[self parseError:error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  50. [alert show];
  51. });
  52. }
  53. NSLog(@"%@", result);
  54.  
  55. //[self checkinMe];
  56.  
  57. }];
  58. }];
  59. }
  60. else
  61. {
  62. [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
  63. NSLog(@"error %@", error.description);
  64. if(error)
  65. {
  66.  
  67. dispatch_async(dispatch_get_main_queue(), ^(void) {
  68. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook error" message:[self parseError:error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  69. [alert show];
  70. });
  71. }
  72. NSLog(@"%@", result);
  73. //[self checkinMe];
  74.  
  75. }];
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement