facebook图api in ios error-未知路径组件

时间:2013-01-22 08:25:47

标签: iphone ios facebook facebook-graph-api

我在ios中使用facebook graph api来分享来自iphone的新闻源。但我得到以下错误:

 {com.facebook.sdk:ParsedJSONResponseKey={
body =     {
    error =         {
        code = 2500;
        message = "Unknown path components: /http://newswatch.nationalgeographic.com/2013/01/20/top-25-wild-bird-photographs-of-the-week-34;
        type = OAuthException;
    };
};
code = 400;

}, com.facebook.sdk:HTTPStatusCode=400}

以下是我在btnClick上分享新闻源的代码的一部分:

if ([strType isEqualToString:@"link"]) {


        text = [[resultArrFeed objectAtIndex:selectedIndex] objectForKey:@"caption"];
        if (text == nil) {
            text = [[resultArrFeed objectAtIndex:selectedIndex] objectForKey:@"name"];
        }
        if (text == nil) {
            text = [[resultArrFeed objectAtIndex:selectedIndex] objectForKey:@"story"];
        }
        NSDictionary *dict = [resultArrFeed objectAtIndex:selectedIndex];



        dic=[NSDictionary  dictionaryWithObjectsAndKeys:text,@"message",nil];
        NSLog(@"%@", dict);
       // NSString *str = [dict valueForKey:@"link"];
        NSString *str = [dict valueForKey:@"link"];
        request=[NSMutableString stringWithString: @"me/feed/"];
        [request appendString:str];
         NSLog(@"appended : %@", request);
    }

如果我尝试共享照片类型的新闻源,相同的代码可以正常工作。我哪里错了?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我收到了错误:正确的代码:

if([strType isEqualToString:@“link”] || [strType isEqualToString:@“video”]){

        text = [[resultArrFeed objectAtIndex:selectedIndex] objectForKey:@"caption"];
        if (text == nil) {
            text = [[resultArrFeed objectAtIndex:selectedIndex] objectForKey:@"name"];
        }
        if (text == nil) {
            text = [[resultArrFeed objectAtIndex:selectedIndex] objectForKey:@"story"];
        }
        NSDictionary *dict = [resultArrFeed objectAtIndex:selectedIndex];

        NSLog(@"%@", dict);

        NSString *str = [dict valueForKey:@"link"];
        dic=[NSDictionary  dictionaryWithObjectsAndKeys:str,@"link",nil];
        request=[NSMutableString stringWithString: @"me/feed/"];

         NSLog(@" %@", dic);
    }

在请求中我们只需要传递给我/ feed和FBRequest的params * friendRequest = [FBRequest requestWithGraphPath:request parameters:dic HTTPMethod:@“POST”];我们需要传递link = http:// ...