API Graph Facebook не публикует сообщение стены с сообщением Objective-C HTTP с использованием JSON - PullRequest
0 голосов
/ 03 ноября 2011
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];

1 Ответ

0 голосов
/ 13 июня 2012
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];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...