English 中文(简体)
如何在目标C中按请求和员额变量张贴按请求打印php脚本的请求
原标题:How to post request to php script with request and post variables in objective C
  • 时间:2012-05-22 20:06:16
  •  标签:
  • php
  • ios

我要从目标- C 代码发送邮件请求到带 URL 的php 脚本

< a href=>http://ggg.abc.com/example.php?MO&email=test@gmail.com&message=TESTMSG&remount=1111111" rel=“nofollow”>http://ggg.abc.com/exampple.php?MO&<[电子邮件保护]

我试图使用ASIFormData Request如下,但我如何在请求中指定请求变量MO?

NSURL* url = [NSURL URLWithString:ServerApiURL];
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];

// Add the POST fields
//[request setPostValue:@"" forKey:@"MO"];
//[request setRequestMethod:@"MO"];

[request setPostValue:@"[email protected]" forKey:@"email"]; 
[request setPostValue:@"TESTMSG" forKey:@"message"];
[request setPostValue:@"11111" forKey:@"recipient"];

还有其他办法吗?

最佳回答

作为最后手段,附录PostData:应该起作用。

< a href=" "http://allseeing-i.com/ ASIHTTP request/ how-to-use" rel=“nofollow" >PUT 请求和自定义 POSTs


如果您想要通过 PUT 发送数据, 或者想要用 POST 发送数据, 但宁愿自己创建 POST 机构, 请使用附件 PostData: 或附件 PostDataFile: 。

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request appendPostData:[@"This is my data" dataUsingEncoding:NSUTF8StringEncoding]];
// Default becomes POST when you use appendPostData: / appendPostDataFromFile: / setPostBody:
[request setRequestMethod:@"PUT"];

如果您想要发送大量数据, 而不使用 ASIFormData Request, 请查看下面磁盘上流出的邮体的信息 。


对你来说,这将是:

NSURL* url = [NSURL URLWithString:ServerApiURL];
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request appendPostData:[@"MO&[email protected]&message=TESTMSG&recipient=11111" dataUsingEncoding:NSUTF8StringEncoding]];

祝你好运


更新对最后最后评论的答复

NSURL* url = [NSURL URLWithString:ServerApiURL];
NSURL* urlWithParams = [NSURL URLWithString:@"?MO&[email protected]&message=TESTMSG&recipient=11111" relativeToURL:url];
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:urlWithParams];
[request setDelegate:self];
// Does this request need to be a post? If so, then call -setRequestMethod:.
// NOTE: I don t know if zero length posts work.
[request setRequestMethod:@"POST"];
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签