简体   繁体   中英

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. All the Ray Wenderlich tutorials are out of date and don't work.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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