使用AFNetworking发布原始文本

时间:2013-06-10 07:36:34

标签: ios afnetworking

我正在使用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]

1 个答案:

答案 0 :(得分: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']) 将导致 - “长访问密钥”