iOS Facebook FQL问题
我正在尝试让以下FQL语句在我的iOS应用程序中工作iOS Facebook FQL问题,ios,objective-c,facebook,cocoa,Ios,Objective C,Facebook,Cocoa,我正在尝试让以下FQL语句在我的iOS应用程序中工作 SELECT comment_info,likes,share_count FROM stream WHERE post_id 出于某种原因,我一直从graph API中得到一个错误 分析错误:位置70处的意外“?”OAuth异常 由于某种原因,该职位会移动,因此会在我的请求末尾添加一个“?”?下面是我正在使用的代码块。现在让我抓狂,因为我已经尝试了很多东西,但仍然无法摆脱这个问题,但是使用相同的方法拉/me/home时效果很好
SELECT comment_info,likes,share_count FROM stream WHERE post_id
出于某种原因,我一直从graph API中得到一个错误
分析错误:位置70处的意外“?”OAuth异常
由于某种原因,该职位会移动,因此会在我的请求末尾添加一个“?”?下面是我正在使用的代码块。现在让我抓狂,因为我已经尝试了很多东西,但仍然无法摆脱这个问题,但是使用相同的方法拉/me/home时效果很好
NSLog(@"ID: %@", graphID);
NSString* urlText = [NSString stringWithFormat: @"https://graph.facebook.com/fql?q=SELECT comment_info,likes,share_count FROM stream WHERE post_id = '%@'", graphID];
urlText = [urlText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString: urlText];
SLRequest * request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters: nil];
request.account = self.facebookAccount;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSLog(@"url %@", request.URL.absoluteURL);
NSString * responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSError* responseError;
NSDictionary* jsonDict = [NSJSONSerialization JSONObjectWithData:[responseString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&responseError];
NSArray * dataArray = jsonDict[@"data"];
[dataArray enumerateObjectsUsingBlock:^(NSDictionary * infoDictionary, NSUInteger idx, BOOL *stop) {
NSNumber *likesCount;
NSNumber *commentsCount;
likesCount = [NSNumber numberWithInt: [infoDictionary[@"likes"][@"count"] integerValue]];
commentsCount = [NSNumber numberWithInt: [infoDictionary[@"comment_info"][@"comment_count"] integerValue]];
NSLog(@"likes %@", likesCount);
}];
}];
我建议您使用带有'q'参数的NSDictionary,如下所示
NSDictionary *params = @{ @"q" : [NSString stringWithFormat: @"https://graph.facebook.com/fql?q=SELECT comment_info,likes,share_count FROM stream WHERE post_id = '%@'", graphID] };
并根据您的请求将其作为参数发送。这是正确的方法
NSString* urlString = @"https://graph.facebook.com/fql";
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString* query = [NSString stringWithFormat:@"SELECT user_id FROM like WHERE post_id='%@' AND user_id=me()", postId];
SLRequest* request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:urlString]
parameters:@{@"q" : query}];
request.account = <account>;
NSString*urlString=@”https://graph.facebook.com/fql";
urlString=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString*query=[NSString stringWithFormat:@“从post_id='%@'和user_id=me()”中选择用户_id,postId];
SLRequest*request=[SLRequestRequestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:urlString]
参数:@{@“q”:query}];
request.account=;
试试这个
NSString*urlString=@
urlString=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
NSString*query=[NSString stringWithFormat:@“选择评论\信息,喜欢,共享\来自流的计数,其中post\ id='%@',graphID]
SLRequest*request=[SLRequestRequestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:urlString]
参数:@{@“q”:query}]
request.account=self.facebookAccount;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error)
{
if(!error)
{
NSDictionary *list =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@data from facebook : %@“,list);
}
else
{
NSLog(@"error while fetching data from facebook : %@",error);
}
}];
NSLog中也没有显示“?”(@“url%@”,request.url.absoluteURL);