Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. - (void) facebookFetch
  2. {
  3. NSString* query = @"<my_query">;
  4. NSDictionary *queryParam = @{ @"q": query };
  5. [FBSettings setLoggingBehavior:[NSSet setWithObjects:
  6. FBLoggingBehaviorFBRequests,
  7. nil]];
  8. // Make the API request that uses FQL
  9. [FBRequestConnection startWithGraphPath:@"/fql"
  10. parameters:queryParam
  11. HTTPMethod:@"GET"
  12. completionHandler:^(FBRequestConnection *connection,
  13. id result,
  14. NSError *error) {
  15. if (error) {
  16. NSLog(@"Error: %@", [error localizedDescription]);
  17. } else {
  18. NSLog(@"Result: %@", result);
  19. }
  20. }];
  21.  
  22. }
  23.  
  24. /** Background task **/
  25. -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  26. {
  27. NSLog(@"####### background task!");
  28.  
  29. if (![FBSession activeSession].isOpen) {
  30. NSLog(@"fbsession is NOT open!");
  31. } else {
  32. NSLog(@"fbsession is open!");
  33. [self facebookFetch];
  34. }
  35.  
  36. completionHandler(UIBackgroundFetchResultNewData);
  37.  
  38. URL: https://graph.facebook.com//fql?sdk=ios&access_token=ACCESS_TOKEN_REMOVED&q=<my_query>&migration_bundle=fbsdk%3A20131212&format=json
  39. Method: GET
  40. UserAgent: FBiOSSDK.3.13.1
  41. MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
  42.  
  43. - (void) facebookFetch:(void (^)(UIBackgroundFetchResult))backgroundCompletion
  44. {
  45. NSString* query = @"<my_query">;
  46. NSDictionary *queryParam = @{ @"q": query };
  47. [FBSettings setLoggingBehavior:[NSSet setWithObjects:
  48. FBLoggingBehaviorFBRequests,
  49. nil]];
  50. // Make the API request that uses FQL
  51. [FBRequestConnection startWithGraphPath:@"/fql"
  52. parameters:queryParam
  53. HTTPMethod:@"GET"
  54. completionHandler:^(FBRequestConnection *connection,
  55. id result,
  56. NSError *error) {
  57. if (error) {
  58. NSLog(@"Error: %@", [error localizedDescription]);
  59. } else {
  60. NSLog(@"Result: %@", result);
  61. }
  62.  
  63. if (backgroundCompletion) {
  64. backgroundCompletion(UIBackgroundFetchResultNewData);
  65. }
  66. }];
  67.  
  68. }
  69.  
  70. /** Background task **/
  71. -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  72. {
  73. NSLog(@"####### background task!");
  74.  
  75. if (![FBSession activeSession].isOpen) {
  76. NSLog(@"fbsession is NOT open!");
  77. } else {
  78. NSLog(@"fbsession is open!");
  79. [self facebookFetch:completionHandler];
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement