gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 13:37:44 27 4
gpt4 key购买 nike

我正在尝试执行一个 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com