Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone:无法在墙上发布图像(facebook)_Iphone_Facebook Graph Api - Fatal编程技术网

iphone:无法在墙上发布图像(facebook)

iphone:无法在墙上发布图像(facebook),iphone,facebook-graph-api,Iphone,Facebook Graph Api,我试图上传一张图片到facebook,我在facebook上获得上传的图片id,在获得该id后,我试图创建一个请求,将该图片id附加到grap库中,但每次都出现错误。该代码最初运行正常,但现在失败了 NSString *message = [NSString stringWithFormat:@"For test only --> I think this its uploaded !"]; NSURL *url = [NSURL URLWithString:@"http

我试图上传一张图片到facebook,我在facebook上获得上传的图片id,在获得该id后,我试图创建一个请求,将该图片id附加到grap库中,但每次都出现错误。该代码最初运行正常,但现在失败了

    NSString *message = [NSString stringWithFormat:@"For test only --> I think this its uploaded !"];

    NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request addFile:savedImagePath forKey:@"file"];
    [request setPostValue:message forKey:@"message"];
    [request setPostValue:_accessToken forKey:@"access_token"];
    [request setDidFinishSelector:@selector(sendToPhotosFinished:)];

    [request setDelegate:self];
    [request startAsynchronous];


}

    - (void)sendToPhotosFinished:(ASIHTTPRequest *)request
{
    // Use when fetching text data
    NSString *responseString = [request responseString];

    NSMutableDictionary *responseJSON = [responseString JSONValue];
    NSString *photoId = [responseJSON objectForKey:@"id"];
    NSLog(@"Photo id is: %@", photoId);

    NSString *urlString = [NSString stringWithFormat:
                           @"https://graph.facebook.com/%@?access_token=%@", photoId, 
                           [_accessToken stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSURL *url = [NSURL URLWithString:urlString];
    ASIHTTPRequest *newRequest = [ASIHTTPRequest requestWithURL:url];
    [newRequest setDidFinishSelector:@selector(getFacebookPhotoFinished:)];

    [newRequest setDelegate:self];
    [newRequest startSynchronous];

}

    - (void)getFacebookPhotoFinished:(ASIHTTPRequest *)request
{
    NSString *responseString = [request responseString];
    NSLog(@"Got Facebook Photo: %@", responseString);

    NSMutableDictionary *responseJSON = [responseString JSONValue];   

    NSString *link = [responseJSON objectForKey:@"link"];
    if (link == nil) return;   
    NSLog(@"Link to photo: %@", link);

    NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
    ASIFormDataRequest *newRequest = [ASIFormDataRequest requestWithURL:url];
    [newRequest setPostValue:@"I'm learning how to post to Facebook from an iPhone app!" forKey:@"message"];
    [newRequest setPostValue:@"Check out the tutorial!" forKey:@"name"];
    [newRequest setPostValue:@"This tutorial shows you how to post to Facebook using the new Open Graph API." forKey:@"caption"];
    [newRequest setPostValue:@"From Ray Wenderlich's blog - an blog about iPhone and iOS development." forKey:@"description"];
    [newRequest setPostValue:@"http://google.com" forKey:@"link"];
    [newRequest setPostValue:link forKey:@"picture"];
    [newRequest setPostValue:_accessToken forKey:@"access_token"];
    [newRequest setDidFinishSelector:@selector(postToWallFinished:)];

    [newRequest setDelegate:self];
    [newRequest startAsynchronous];

}

    - (void)postToWallFinished:(ASIHTTPRequest *)request
{
    NSString *responseString = [request responseString];

    NSMutableDictionary *responseJSON = [responseString JSONValue];
    NSString *postId = [responseJSON objectForKey:@"id"];
    NSLog(@"Post id is: %@", postId);

    UIAlertView *av = [[[UIAlertView alloc] 
                        initWithTitle:@"Sucessfully posted to photos & wall!" 
                        message:@"Check out your Facebook to see!"
                        delegate:nil 
                        cancelButtonTitle:@"OK"
                        otherButtonTitles:nil] autorelease];
    [av show];

}
错误是

-JSONValue失败。错误跟踪是:( “Error Domain=org.brautaset.JSON.ErrorDomain Code=4\”有效片段,但不是JSON\“UserInfo=0x6078ae0{NSLocalizedDescription=Valid fragment,但不是JSON}”

请告诉我这件事

问候 安基特