开发者

Facebook Graph API Crashing My App

开发者 https://www.devze.com 2023-03-16 22:55 出处:网络
he problem is when i come to use the post function a section time. The app will crash out kicking out the error below...

he problem is when i come to use the post function a section time. The app will crash out kicking out the error below... Program received signal: “EXC_BAD_ACCESS”.

I'm using the code below .But image is post to Facebook.

NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];

//create a UIImage (you could use the picture album or camera too)

NSData *imageData = UIImageJPEGRepresentation(imgView.image, 8.0);
UIImage *picture = [UIImage imageWithData:imageData];

//create a FbGraphFile object insance and set the picture we wish to publish on it
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];

//finally, set the FbGraphFileobject onto our variables dictionary....
[variables setObject:graph_file forKey:@"file"];    
[variables setObject:@"i'm testing my iPhone App" forKey:@"message"];

//the fbGraph object is smart enough to recognize the binary image data inside the FbGraphFile
//object and treat that is such.....
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"117795728310/photos" withPostVars:variables];
NSLog(@"postPictureButtonPressed:  %@", fb_graph_response.htmlResponse);    
NSLog(@"Now log into Facebook and look at your profile & photo albums...");

Plz help me for solving this 开发者_JAVA百科problem.


 NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:1];

    NSData *dataImage=UIImageJPEGRepresentation(FilterImage, 1.0);
    UIImage *picture =[[UIImage alloc]initWithData:dataImage];
    FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
    [variables setObject:graph_file forKey:@"file"];
    //[variables setObject:[NSString stringWithFormat:@"Testing App"] forKey:@"message"];
    [fbGraph doGraphPost:@"me/photos" withPostVars:variables];
    NSLog(@"Now log into Facebook and look at your profile & photo albums...");
    [picture release];
    picture=nil;


NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];

replace above

NSMutableDictionary *variables = [[NSMutableDictionary alloc] initWithCapacity:2];
0

精彩评论

暂无评论...
验证码 换一张
取 消