0

アプリから http リクエストを送信して Facebook オープン グラフ オブジェクトを作成したいのですが、Facebook SDK を使用していません。ソーシャル ネットワーク フレームワークを使用しており、AFNetworking でグラフを開くリクエストを作成しています。私のコード:

    - (void)didInitializeSocialAccountStore:(BOOL)succes forPermissions:(AccountStorePermissions)permissionsType
    {
        NSURLRequest *request = [self requestWithMethod:@"POST" path:[NSString stringWithFormat:@"https://graph.facebook.com/me/objects/myapp:comments?access_token=%@", [MGSocialNetworkSingleton sharedInstance].facebookAccesToken] parameters:self.exampleObject];

        if (permissionsType == AccountStorePermissions_Publish)
        {

            AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
                DLog(@"response: %@\n", response);
                DLog(@"JSON: %@\n", JSON);
                DLog(@"URL: %@\n", request.URL);
            } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
                DLog(@"response: %@\n", response);
                DLog(@"error: %@\n", error);
                DLog(@"JSON: %@\n", JSON);
                DLog(@"URL: %@\n", response.URL);
            }];
            [operation start];
        }    
}
- (NSDictionary *)exampleObject
{
    return @{@"object":@{@"title":@"Titleeeee"}};
}

リクエストが行われた後、私はこのエラー応答を取得しています:

didInitializeSocialAccountStore:forPermissions:]_block_invoke_2 [432行目] JSON: { error = { code = 100; message = "(#100) パラメータ オブジェクトが必要です"; タイプ = OAuthException; }; }

私もこの方法を使用しています:

[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
[self setParameterEncoding:AFJSONParameterEncoding];
[self setDefaultHeader:@"Accept" value:@"application/json"];

したがって、exampleObject NSDictionary は自動的に JSON に変換される必要があります

編集

この curl コマンドは正常に機能します。

curl -X POST " https://graph.facebook.com/me/objects/myapp:comments " -F "access_token=CAAH3rJC7RHUBAHP6NHGaa5Pr2MKlJT4X9GZBZBkc93T9TNHqoSV411eD2uvOw2XInpZCZBryY4V6OtvHP5xMDZCJfyiieTe8IB1lS68gYkNlKj6bNYfcsPZCGpamC2wWVJDkAYm9hVHI3fASDGxbHKWUQYam8JZAwblA68y8HXZA1v2EaDZAe3VabyJQ37Q5rf6JVpWiRV50dKH9XSa7I7ZAcg9QajPhWnk3PEZD" -F "object={\"title\":\"Titleeeee\"}"

4

1 に答える 1