1
我我的iOS原生應用程序當前連接到一個Facebook頁面,以發佈消息牆。我可以訪問牆,但由於某種原因,沒有消息文本集。我問用戶'publish_stream'的權限。後發送到從頁面的iOS與publish_stream許可
任何想法我做錯了什麼?這裏是我的代碼:
NSMutableDictionary *message = [NSDictionary dictionaryWithObjectsAndKeys:@"some text", @"message", @"http://path/to/itunes/", @"link", nil];
NSString *changeJSON = [message JSONRepresentation];
NSLog(@"changeJSON: %@", changeJSON);
NSData *myPostData = [changeJSON dataUsingEncoding:NSUTF8StringEncoding];
NSString *myURL = [NSString stringWithFormat:@"https://graph.facebook.com/pageId/feed?access_token=%@", facebook.accessToken];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:myURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [myPostData length] ] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: myPostData];
NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];
NSLog(@"return string: %@", returnString);
[facebook logout:self];
被編碼到一個NSData對象的字符串如下:
{"message":"some text","link":"http://path/to/itunes/"}
感謝,並有一個愉快的一天:-)
感謝的人,這就是解決方案。現在我的錯誤就像魅力一樣工作:-) – MrBr