Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Share image on facebook using ASIFormDataRequest

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 517
    Comment on it

    Below is the code for sharing photo on facebook using ASIHTTPRequest.

     - (void)publishStoryWithImage:(UIImage*)image andMessage:(NSString*)message
    {
        NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
        ASIFormDataRequest *newRequest = [ASIFormDataRequest requestWithURL:url];
        [newRequest setPostValue:message forKey:@"message"];
        NSData *imageData = UIImageJPEGRepresentation(image, 0.2f);
        [newRequest addData:imageData withFileName:@"testPicture" andContentType:@"multipart/form-data" forKey:@"source"];
        [newRequest setPostValue:yourAccessToken forKey:@"access_token"];
        [newRequest setRequestMethod:@"POST"];
        [newRequest setDidFinishSelector:@selector(postImageOnFacebookFinished:)];
        [newRequest setDidFailSelector:@selector(postImageOnFacebookfailed:)];
        [newRequest setDelegate:self];
        [newRequest startAsynchronous];
    
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: