0

我正在使用AFNetworking并且正在尝试执行原始文本。当我浏览文档时,我似乎可以附加一个数据字典,但我无法弄清楚如何传递原始文本。我要传递的原始文本是:

{
 Email : "name@company.com"
 , Password : "password"
 , Accesskey : "long access key"
}

我想使用的示例代码片段如下。问题是我想传递原始文本,下面的示例需要一个NSDictionary(参数),而我只是想传递一个字符串。

       [client postPath:@"weather.php"
          parameters:parameters
             success:^(AFHTTPRequestOperation *operation, id responseObject) {
                 self.weather = responseObject;
                 self.title = @"HTTP POST";
                 [self.tableView reloadData];
             }
             failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                 UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Weather"
                                                              message:[NSString stringWithFormat:@"%@",error]
4

1 回答 1

0

你为什么要这样做?刚刚发布

NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
    [parameters setObject:@"name@company.com" forKey:@"Email"];
    [parameters setObject:@"password" forKey:@"Password"];
    [parameters setObject:@"long access key" forKey:@"Accesskey"];

上服务器(PHP)print_r($_POST['Accesskey']) 将导致 - “长访问密钥”

于 2013-06-10T07:49:45.327 回答