2011-11-03 4 views
0
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]; 

답변

0
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]; 
관련 문제