我是IOS的新手。 我试图调用Facebook Graph URL来获取JSON数据&解析它 -
NSString *urlStr = @"https://graph.facebook.com/102555409843504_373792589386450";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlStr]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:10];
[request setHTTPMethod: @"GET"];
NSError *requestError;
NSURLResponse *urlResponse = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
但是它的返回错误 -
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
- 我有一个有效的会话,但不知道如何使用它来调用图形API。
答案 0 :(得分:2)
如果您在浏览器中请求此URL,您将获得相同的结果:
https://graph.facebook.com/102555409843504_373792589386450
问题是你没有传递access_token
。因此,检索数据的正确方法是:
https://graph.facebook.com/102555409843504_373792589386450?access_token=SECRET
出于测试目的,您可以从以下位置获取Graph API资源管理器中的令牌: