English 中文(简体)
• 如何通过电话应用卸载照片/录像
原标题:how to uload photo/image to facebook via iphone application

i am integrating facebook with my iphone application. i can share text message in facebook, but i want to share/ upload photos to facebook through my iphone application. please let me know is there soution for this. i am trying the facebook sample code but it is giving me some errors: i searched out that error but other developer also facing this type of error. please let me know if there is some one who did upload/ share a photo on facebook in iphone application.

提前感谢。

最佳回答

您需要制作一个顶版图像的画册,然后是用面对面的胶卷制作的。

// for making a facebook album u have to make a multi-part form request
//to this url https://graph.facebook.com/100002232753228/albums
//where 100002232753228 is the fbid of the user and with form fields access_token,name,message, for reference go to -http://developers.facebook.com/docs/reference/api/album/

//To upload a foto to album send multi-part data to the url - https://graph.facebook.com/102657189818706/photos

//where 102657189818706 is the facebook id of the album created

这里是法典

#define kRequestBoundary @"----FOO"

    NSMutableData *postBody = [[NSMutableData alloc] init]; 
    [postBody appendData:[[NSString stringWithFormat:@"--%@
", kRequestBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; //starting the boundary of form data

                        [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name="access_token"

"] dataUsingEncoding:NSUTF8StringEncoding]]; //setting field name of access_toke 
                        [postBody appendData:[[NSString stringWithString:@"200726069952695|fd9c7d8ed4b5592b1240cdb3-100002232753228|i7ae5By6VFItLliVT1jw5jsETEY"] dataUsingEncoding:NSUTF8StringEncoding]];
    //setting field value of access_token

    [postBody appendData:[[NSString stringWithFormat:@"
--%@
", kRequestBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; //closing the boundary for next field

    [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name="image"; filename="UserImage.png"
"] dataUsingEncoding:NSUTF8StringEncoding]];
//setting the field name of image

    [postBody appendData:[[NSString stringWithString:@"Content-Type: image/png

"] dataUsingEncoding:NSUTF8StringEncoding]]; //setting the content-Type of image



        UIImage *cropped=[UIImage imageNamed:@"Sample.png"];



    NSData *pImageData = UIImagePNGRepresentation(cropped);


    [postBody appendData:pImageData]; // adding image data to the request data

    [postBody appendData:[[NSString stringWithFormat:@"
--%@--
",kRequestBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; //closing the 


    NSString *urlString = @"https://graph.facebook.com/102657189818706/photos";


    NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:pUrl]];
    self.mURLrequest=request;
    [request release];
    [pUrl release];
    [request setHTTPMethod:@"POST"];

    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kRequestBoundary];

    [request setValue:contentType forHTTPHeaderField:@"Content-type"];
    [mURLrequest setHTTPBody:postBody];


    NSURLConnection *temp=[[NSURLConnection alloc] initWithRequest:mURLrequest delegate:self];
[temp autorelease];
问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签