0

iOSアプリで次のFQLステートメントを機能させようとしています

SELECT comment_info,likes,share_count FROM stream WHERE post_id

何らかの理由で、グラフAPIからエラーが発生し続けます

解析エラー: 予期しない「?」位置 70 OAuth 例外

位置が動くのでなぜか「?」SLRequests の末尾に追加されていますか? これが私が使用しているコードのブロックです。私は多くのことを試しましたが、まだこれを取り除くことはできませんが、同じ方法を使用して /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);
            }];
        }];
4

3 に答える 3

1

これが正しいアプローチです

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>;
于 2014-01-08T05:29:10.967 に答える
0

これを試してみてください

NSString* urlString = @" https://graph.facebook.com/fql ";

urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSString* query = [NSString stringWithFormat:@"SELECT comment_info,likes,share_count FROM stream WHERE post_id = '%@'", graphID];

SLRequest* request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:urlString] parameters:@{@"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);
     }


 }];
于 2014-04-02T12:42:02.933 に答える
0

このように '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] };

SLRequest で params として送信します。

于 2013-06-07T20:06:59.053 に答える