简体   繁体   English

在不使用iOS SDK的情况下使用Facebook Graph API

[英]Using the Facebook Graph API without using the iOS SDK

Please can anyone tell me how to post images / albums and likes to Facebook, WITHOUT using their SDK / iOS libraries, ie doing it with complete custom code. 请任何人告诉我如何在不使用其SDK / iOS库的情况下将图像/相册和喜欢的图像发布到Facebook,即使用完整的自定义代码进行操作。 All the Ray Wenderlich tutorials are out of date and don't work. 所有的Ray Wenderlich教程都已过时,无法正常工作。

I can't get it to work. 我无法正常工作。

Here is the solution for all those that have had the same problem: 这是所有遇到相同问题的解决方案:

- ( BOOL ) postImageData:( NSData * )imageData toWall:( NSString * )wallID withFilename:( NSString * )filename asynchronously:( BOOL )decision
{
    NSString * stringURL = [NSString stringWithFormat:@"%@me/photos?access_token=%@", fbGraphAPIRoot, self.accessToken];
    NSURL * url = [NSURL URLWithString:stringURL];

    ASIFormDataRequest * request = [ASIFormDataRequest requestWithURL:url];

    [request setData:imageData withFileName:filename andContentType:@"image/jpeg" forKey:@"file"];
    [request setRequestMethod:@"POST"];
    [request setDidFinishSelector:@selector( postToFacebookSucceeded: )];
    [request setDidFailSelector:@selector( postToFacebookFailed: )];
    [request setDelegate:self];

    if ( decision == YES )
    {
        [request startAsynchronous];
    }
    else
    {
        [request startSynchronous];
    }

    return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM