I went over the Facebook developer docs and generally around the internet but couldn't quite understand how to use the Facebook Graph API in iOS.
Specifically, I need to fetch a list of nearby locations using a given latitude&longitude. I came across this:
GET /search?q={query}&type=place¢er={lat},{lng}&distance={distance}
But I don't understand where to even begin.
I have the Facebook SDK set up.
How do I call such request?
Thanks in advance
I think that you need to use the Facebook Graph request methods, some thing like this
NSDictionary *params = @{@"fields" : @"", @"redirect" : @NO, @"type" : @"large"};
NSString *getPath = [NSString stringWithFormat:@"/%@/picture", @"fabebook_user_id"];
FBSDKGraphRequest *photoRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:getPath parameters:params HTTPMethod:@"GET"];
with this method i am getting the user photo, I think so this method can be useful for you too :)
I managed by performing a simple URL request:
if let accessToken: FBSDKAccessToken? = FBSDKAccessToken.currentAccessToken() {
let urlString = "https://graph.facebook.com/search?type=place¢er=\(geoPoint!.latitude),\(geoPoint!.longitude)&distance=1000&limit=10&access_token=\(accessToken!.tokenString)"
let URL = NSURL(string: urlString)!
let request = NSMutableURLRequest(URL: URL)
request.HTTPMethod = "GET"
let task = NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if response != nil {
let json = try! NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers)
print(json)
}
})
task.resume()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.