2012-09-14 79 views
0

我有一个PHP脚本,我想发送参数给它。在Android我成功地使用该代码:发送参数到php脚本在ios

你能帮我在Obj-C中的等效代码吗?

nameValuePairs.add(new BasicNameValuePair("table", table)); 
     nameValuePairs.add(new BasicNameValuePair("code", Integer.toString(code))); 
     nameValuePairs.add(new BasicNameValuePair("name", temp_name)); 
     nameValuePairs.add(new BasicNameValuePair("email", email)); 

我知道如何从php获取数据或调用一个http脚本,我只是不知道热这些参数发送到php。

在PHP端我的代码是这样的:

$table.=$_POST['table']; 
$code.=$_POST['code']; 
$name.=$_POST['name']; 
$email.=$_POST['email']; 

回答

1

证据是在布丁:iOS: how to perform a HTTP POST request?

我虽然建议,您使用NSDictionary对象来保存你的价值观和JSON编码。获取JSON数据并将其提交给服务器。在您的PHP脚本中使用JSON解码来解码和处理结果。