Facebook Graph API not posting wall message with Objective-C HTTP post using JSON

NSDictionary *messageParams1 = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"string sterinfsd;fs;d "],@"message",nil];
NSString *postString = [messageParams1 JSONRepresentation];

NSData *myPostData = [postString dataUsingEncoding:NSUTF8StringEncoding]; // StringEncoding];
NSString *strMyUrl1 = [NSString stringWithFormat:@"https://graph.facebook.com/me/feed?access_token=%@",facebook.accessToken];
NSURL *myUrl1 = [NSURL URLWithString:strMyUrl1];

NSMutableURLRequest *myUrlRequest = [[NSMutableURLRequest alloc] initWithURL:myUrl1 cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0f];

int count = [myPostData length];
[myUrlRequest setHTTPMethod:@"POST"];
[myUrlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[myUrlRequest setValue:[NSString stringWithFormat:@"%d", count ] forHTTPHeaderField:@"Content-Length"];
[myUrlRequest setHTTPBody: myPostData];

NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:myUrlRequest delegate:self];
[connection start];

Answers


const char *bytes = [[NSString stringWithFormat:@"message=hello GUys"] UTF8String];

NSString *urlString = [NSString stringWithFormat:@"https://graph.facebook.com/me/feed?access_token=%@",[default1 objectForKey:@"accessToken"]];

NSURL *Url = [NSURL URLWithString:urlString];

NSMutableURLRequest *UrlRequest = [[NSMutableURLRequest alloc] initWithURL:Url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0f];

[UrlRequest setHTTPMethod:@"POST"];
   [UrlRequest setHTTPBody:[NSData dataWithBytes:bytes length:strlen(bytes)]];

NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:UrlRequest delegate:self];
[connection start];

Need Your Help

Core Data Inferred Migration – Automatic "lightweight" vs Manual

iphone objective-c core-data migration mapping-model

I've updated the model of an existing iPhone app in some simple ways (remove attribute, add attribute, remove index), and can use automatic lightweight migration to migrate the persistent store.

Start a CSS transition via JS does not work

javascript jquery html css css3

I want to start a CSS transition, that changes the background-color and the dimension if a button is clicked. But there is a mistake in the code: