AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://graph.facebook.com/"]]; NSString *link = [NSString stringWithFormat:@"https://graph.facebook.com/%@/likes/%@", USER_ID, PAGE_ID]; NSDictionary *params = @{@"access_token" : [[[FBSession activeSession] accessTokenData] accessToken]}; NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" path:link parameters:params]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON ) { if([[JSON objectForKey:@"data"] count] == 0){ // The page is not liked. } else{ // The user likes the page. } } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){ }]; [operation start];That's it, don't hesitate to comment, to share your knowledge and to correct me.
Sunday, August 4, 2013
Check if a Facebook page is liked using AFNetworking.
Posted by Polaris on 11:45 AM
Subscribe to:
Post Comments (Atom)
Thank you very much! Really helped me a lot! :)
ReplyDelete