我想做这样的事情:
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(" http://www.somepage.com?par1=val1&par2=val2 "));
但我不想发送参数与get但是发帖.我怎么能这样做?
非常感谢纳瓦霍人
所以我们有一个取消订阅链接 - 这本质上是HTTP GET.
在适当的RFC说,这应该是幂等的,但在我看来,用户的预期将是他们点击一个链接来采取行动.
我已经实现了这一点,以便链接将您带到一个具有大确认按钮的页面,然后更新您的订阅,确认并显示您帐户的最终状态(我们有多种类型的订阅)
但我想知道如果这个人只是跳过确认按钮阶段它不会是一个更好的用户体验......
问题的答案"我是否过度思考这个问题?" 肯定是的,但我想知道人们对平衡幂等GET的最佳实践与不混淆用户期望的最佳实践的看法......
我的目标是通过HTTP post上传文本文件我正在使用Delphi 2009.
比如说以下网址
https://www.example.com/ex/exampleAPI.asmx/Process
我知道可以使用TIdHttp组件来完成.以下是电话
IdHttp1.Post();
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何设置所有内容,即指定网址并包含要发布的文件.
谢谢.
基本上我只想从服务器获取cookie.这里是简单的代码,但我想这并不足以获得每个cookie,例如sessionID等.
import java.net.*;
import java.util.*;
public class Cookie {
public static void main(String[] args) {
try {
URL url = new URL("http://www.google.com/");
URLConnection conn = url.openConnection();
System.out.println(con.getHeaderField("Set-Cookie"));
} catch (Exception e) { }
}
}
Run Code Online (Sandbox Code Playgroud)
结果显示我只获得一个cookie:
NID=61=nNSsAl4g7DfxqHE7t__ghfoCc_J-RmY7PaTNoPOd_khLdvvuqI-fnteHgnQXMzmxj_C5HdMozcGfOTt8PvePLKpbDdUlzdVZiRKwNpQIej6_T69jt9C7Oi6E4F-gWPHD; expires=Mon, 14-Jan-2013 17:16:40 GMT; path=/; domain=.google.pl; HttpOnly
Run Code Online (Sandbox Code Playgroud)
Firefox获得NID和PREF,因此无法正常工作.
有没有办法获得PREF cookie?
任何人都可以告诉我这是发送POST的正确方法(下面的代码).
import java.io.*;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
public class Cookie_Example {
public static void main(String[] args){
try{
String https_url = "https://ssl.filmweb.pl/j_login";
URL url = new URL(https_url);
String …Run Code Online (Sandbox Code Playgroud) 我在这个POST请求上收到400个错误请求.知道这里的问题是什么吗?日志在这里.
调节器
@Controller
public class AjaxController {
@RequestMapping(value="/addKeys", method=RequestMethod.POST, consumes="application/json; charset=UTF-8")
public ResponseEntity<String> addKeys(@RequestParam(value="keys") ArrayList<Keys> keys){
System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"+keys);
}
}
Run Code Online (Sandbox Code Playgroud)
上下文servlet.xml中
<beans>
<mvc:annotation-driven />
<context:component-scan base-package="com.canon.fw.controller" />
<bean id="defaultViews" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</beans>
Run Code Online (Sandbox Code Playgroud)
阿贾克斯
tmpList = '[{"key":"camera","label":"Camera"},{"key":"mobile","label":"Mobile"}]';
$.ajax({
type: 'POST',
url: ctx+'/ajx/addKeys',
data: JSON.stringify({"keys": tmpList }),
success: function(r){
if(r.model.status=='success'){
debugger;
//glist.push(elem.key);
//addToList(elem.key, elem.label);
highlightInfoDisc();
}
},
dataType: 'json',
contentType: 'application/json'
});
Run Code Online (Sandbox Code Playgroud)
FireBug - URL
http://localhost:8080/Di/ajx/addKeys
Run Code Online (Sandbox Code Playgroud)
Firebug - 响应标题
Cache-Control must-revalidate,no-cache,no-store
Content-Length 1384
Content-Type text/html; charset=iso-8859-1
Server Jetty(6.1.26)
Run Code Online (Sandbox Code Playgroud)
Firebug - 请求标题 …
我想使用谷歌应用程序脚本进行HTTP POST.我发现这方面的文件很少,也许有人可以帮忙吗?
HTTP POST将是一个名为'Twilio'的服务:
https://www.twilio.com/docs/api/rest/sending-sms
该页面说我的POST中只需要三个参数:
我希望HTTP Post会调用Twilio来发送短信.
最后,我想从谷歌电子表格中获取这些参数.我可以自己做,因为我对Apps脚本相当熟悉,但我从未做过HTTP POST,所以现在(为了简单起见)我只是自己在代码中输入这些参数.
如果有人知道如何做到这一点,或者使用Apps脚本进行任何类型的HTTP POST,请告诉我 - 我花了好几个小时试图解决这个问题!
我想从" http://www.indiapost.gov.in/pin/ " 废弃PINCODE ,我正在编写以下代码.
import urllib
import urllib2
headers = {
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Origin': 'http://www.indiapost.gov.in',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': 'http://www.indiapost.gov.in/pin/',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
}
viewstate = 'JulXDv576ZUXoVOwThQQj4bDuseXWDCZMP0tt+HYkdHOVPbx++G8yMISvTybsnQlNN76EX/...'
eventvalidation = '8xJw9GG8LMh6A/b6/jOWr970cQCHEj95/6ezvXAqkQ/C1At06MdFIy7+iyzh7813e1/3Elx...'
url = 'http://www.indiapost.gov.in/pin/'
formData = (
('__EVENTVALIDATION', eventvalidation),
('__EVENTTARGET',''),
('__EVENTARGUMENT',''),
('__VIEWSTATE', viewstate),
('__VIEWSTATEENCRYPTED',''),
('__EVENTVALIDATION', eventvalidation),
('txt_offname',''),
('ddl_dist','0'),
('txt_dist_on',''),
('ddl_state','2'),
('btn_state','Search'),
('txt_stateon',''),
('hdn_tabchoice','3')
)
from urllib import FancyURLopener
class MyOpener(FancyURLopener):
version = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, …Run Code Online (Sandbox Code Playgroud) 我需要对我的谷歌表单进行Http POST,并按照建议(http://productforums.google.com/forum/#!topic/docs/iCfNwOliYKY)创建了这样的URL语法:
https://docs.google.com/forms/d/MY_FORM_ID&entry.2087820476=hello&entry.261928712=dear&submit=Submit
最终我将从iOS和Android进行POST,但我只是在浏览器中测试它并不起作用.我收到了Google云端硬盘的回复,上面写着"抱歉,您请求的文件不存在." 并且该条目不会进入我的回复电子表格.
我错过了什么?我到处看,但似乎没有回答这个问题.
编辑:
我猜有时最好直接在目标平台上进行测试.以下代码适用于iOS:
NSString *post = @"&key1=val1&key2=val2";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"https://docs.google.com/forms/d/MY_FORM_ID/formResponse"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init];
[NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
Run Code Online (Sandbox Code Playgroud) 我有一个反馈表单,但是当它涉及变音符号(元音变异)时它是不稳定的.例如,有时它会将'ö'显示为'ö'(正确),但有时我会得到一些奇怪的东西,比如'Hร¼ttenkäse'而不是'Hüttenkäse'.
页面编码(在Dreamweaver中)设置为Unicode(UTF-8),在phpmailer中我也改变了它:
/**
* The character set of the message.
* @type string
*/
public $CharSet = 'UTF-8';
Run Code Online (Sandbox Code Playgroud)
我在send.php的开头尝试了以下内容:
header('charset=utf-8');
Run Code Online (Sandbox Code Playgroud)
但我收到了来自服务器的错误消息,虽然邮件已发送,但主题中没有正确的破坏声,所以这似乎不起作用.
send.php由此表单触发:
<form method="post" action="send.php">
Run Code Online (Sandbox Code Playgroud)
send.php看起来像这样:
<?php
require_once("includes/phpMailer/class.phpmailer.php");
require_once("includes/phpMailer/class.smtp.php");
require_once("includes/phpMailer/language/phpmailer.lang-de.php");
$dl = $_GET['dienstleistung'];
$vorn = $_POST['vorname']; // für Vorname falls keine Anrede
$anredeGross = ucfirst($_POST[anrede]);
if ($anredeGross === "Herr") {
$anredeGross = $anredeGross . "n";
} elseif ($anredeGross === "Leer") {
$anredeGross = $vorn;
} else {
$anredeGross = $anredeGross;
}
$firma = $_POST['firma'];
if ($firma !=='') {
$firma = …Run Code Online (Sandbox Code Playgroud)我是角度2的新手,我面临一个问题,我无法找到解决方案:当我尝试从角度2发布到API我得到 - 415不支持的媒体类型.
Angular 2代码:
onSubmit(value: any) {
// console.log(value.message);
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
let creds = 'statusuknown';
let body = JSON.stringify(creds);
this.http.post('http://localhost:1318/api/ActionItem', creds)
.subscribe(
() => {console.log('Success')},
err => {console.error(err)}
);
}
Run Code Online (Sandbox Code Playgroud)
我的控制器代码:
// POST api/actionitem
[HttpPost]
public ActionItem Post( [FromBody]string str)// _id, string _status)
{
ActionItem item = new ActionItem( 313, str);
return item;
}
Run Code Online (Sandbox Code Playgroud)
当我将控制器代码更改为不从主体获取数据时,它可以工作但是引用NULL.
http-post ×10
http ×2
android ×1
angular ×1
api ×1
cookies ×1
delphi ×1
delphi-2009 ×1
diacritics ×1
file-upload ×1
forms ×1
google-forms ×1
idempotent ×1
indy ×1
java ×1
jquery ×1
php ×1
phpmailer ×1
post ×1
python ×1
spring-mvc ×1
web-scraping ×1