php - 使用 objective-c 执行 PHP 脚本

标签 php iphone objective-c ios

我正在尝试执行一个 PHP 脚本来递增数据库中的一个字段。我的脚本正在运行,目前我正在使用 ASIHTTPRequest 完美地修改数据库,但我觉得我应该使用不同的方法,因为我不需要返回。

这就是所谓的 HTTP POST 吗?

    incrementOrDecrementURL = [[NSString alloc] initWithFormat:@"http://myURL/doScript.php"];

NSURL *requestURL = [[NSURL alloc] initWithString:incrementOrDecrementURL];

//The actual request
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:requestURL];
// Becoming the request delegate
//To get callbacks like requestFinished: or requestFailed:
[request setDelegate:self];    

// Start request
[request startAsynchronous]; 

最佳答案

形成docs: Sending a form POST with ASIFormDataRequest

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];

但还要注意,ASIHTTPRequest 不是 maintained anymore by it's original author.

关于php - 使用 objective-c 执行 PHP 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10060152/

相关文章:

php - 函数未在预期位置返回程序的控制权

php - 使用 json_encode() 引号中的数字

java - 如何解决数据冲突

iphone - 您可以使用 iPhone 作为 Web 开发人员吗?服务器?

javascript - jQueryMobile 无法获取 iPhone 上输入文本框的值

ios - 使用 RestKit 执行同步请求

php - PHP,线程和 curl

iphone - iPhone 上的透明 UITableView?

ios - 使用自动布局时删除 UILabel 填充/边距

ios - 将数据保存到另一个用户对象