我正在设置我的网站,通过短信接收来自人们的信息.它的工作方式是文本编号,然后该服务将HTTP POST发送到我指定的URL.我听说.asmx文件比.aspx文件更好,因为它们不会经历整个页面生命周期.但是,我真的不明白如何运行.asmx文件,甚至可以通过POST调用它,即www.mysite.com/webservice.asmx?我知道我可以使用.aspx文件,但我想在我开展这项工作之前检查是否有更好的方法.
感谢您的见解!
我需要在C#中编写一个表单应用程序,通过HTTP POST将参数发送到url,然后获取响应.
我真的没有意识到从哪里开始,这有可能吗?
提前谢谢,加尔.
所以我正在运行它来检索我的POST数据:
$jsonString = file_get_contents('php://input');
Run Code Online (Sandbox Code Playgroud)
如果我去打印出来$jsonString,我会得到如下结果:
东西=价值与OtherThing =价值与ETC = Yougetmydrift
现在,我已经能够做到这一点:
$object = json_decode($jsonString);
$something = $object->Something;
echo $something; // would print 'Value'
Run Code Online (Sandbox Code Playgroud)
但我目前正在经历这种不起作用.我正在使用Android SDK,而php://input后端似乎没有返回任何内容.有人知道为什么吗?
我一直在处理BlackBerry post请求,请求已经发送,但参数似乎不是.这是我的代码:
HttpConnection httpConnection = (HttpConnection) Connector.open(url);
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false);
encPostData.append("time", "1314144000");
System.out.println("url: " + httpConnection.getURL());
byte[] postData = encPostData.toString().getBytes("UTF-8");
System.out.println("post data: " + encPostData.toString());
httpConnection.setRequestProperty("Content-length", String.valueOf(postData.length));
System.out.println("url: " + httpConnection.getURL());
System.out.println("message:" + httpConnection.getResponseMessage());
OutputStream os = httpConnection.openOutputStream();
os.write(postData);
os.flush();
os.close();
Run Code Online (Sandbox Code Playgroud)
我从服务器(我们设置)获得的响应是我们没有发送时间戳.我的问题有问题吗?
encPostData.append("time", "1314144000");
Run Code Online (Sandbox Code Playgroud)
码?
我正在尝试访问Google Search Appliance API:http://code.google.com/apis/searchappliance/documentation/612/gdata/acapi_protocol.html
为了发送请求,我使用curl.我的问题是,当我尝试登录时,使用
curl -k -X POST https://ip.ad.dr.ess:8443/accounts/ClientLogin&Email=username&Passwd=password
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
'Email' is not recognized as an internal or external command,
operable program or batch file.
Passwd: unknown user =password
Run Code Online (Sandbox Code Playgroud)
任何有关此问题的帮助将不胜感激.我是新来的卷曲,所以我意识到我可能错了.
我在Windows 7上通过cygwin安装了curl.
我试图将游戏高分发布到我的数据库表,但我无法弄清楚如何通过传递整数值,只传递字符串.以下是我想在游戏结束时调用的方法,这应该将分数插入到我的表的分数列中.
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://deucalion0.co.uk/insert.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("score", finalscore)); //"score" is the name of the database table, finalscore is the integer that contains the value
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// …Run Code Online (Sandbox Code Playgroud) 我对Android很新.所以,我正在使用Json Data在Android中遇到HttpPost.
JSONObject jsonObj = new JSONObject();
JSONObject jsonObjDasUser = new JSONObject();
jsonObj.put("name", "Login");
jsonObj.put("type", "request");
jsonObj.put("UserCredential", jsonObjUserCredential );
jsonObjUserCredential .put("username", id);
jsonObjUserCredential .put("password", password);
// Create the POST object and add the parameters
HttpPost httpPost = new HttpPost(url);
StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8);
entity.setContentType("application/json");
httpPost.setEntity(entity);
HttpClient client = new DefaultHttpClient();
Run Code Online (Sandbox Code Playgroud)
如何将jsonObjUserCredential包含为:::
//StringEntity userCredential = new StringEntity(jsonObjUserCredential .toString(),HTTP.UTF_8);??????
Run Code Online (Sandbox Code Playgroud)
这里做错了什么?????
请帮我....
我的脚本不起作用.AJAX调用没有发生.为什么?
// ==UserScript==
// @name prova
// @namespace http://blogpagliaccio.wordpress.com/
// @description prova
// @include http://*
// @version 1
// @grant GM_xmlhttpRequest
// @require http://userscripts.org/scripts/source/85398.user.js
// ==/UserScript==
// [........... other code]
console.log('start ajax call...');
GM_xmlhttpRequest({
method: "POST",
url: "www.prova.it",
data: {parametro:parametro},
onload: function(response) {
console.log(response.responseText);
},
onerror: function(reponse) {
alert('error');
console.log(reponse);
}
});
Run Code Online (Sandbox Code Playgroud)
我在一个@grant指令中列出了API函数,但是我没有看到AJAX调用和响应.
from bs4 import BeautifulSoup
import requests
from requests.auth import HTTPProxyAuth
url = "http://www.transtats.bts.gov/Data_Elements.aspx?Data=2"
proxies = {"http":"xxx.xxx.x.xxx: port"}
auth = HTTPProxyAuth("username", "password")
r = requests.get(url, proxies=proxies, auth=auth)
soup = BeautifulSoup(r.text,"html.parser")
viewstate_element = soup.find(id = "__VIEWSTATE").attrs
viewstate = viewstate_element["value"]
eventvalidation_element = soup.find(id="__EVENTVALIDATION").attrs
eventvalidation = eventvalidation_element["value"]
data = {'AirportList':"BOS",'CarrierList':"VX",'Submit':'Submit',"__EVENTTARGET":"","__EVENTARGUMENT":"","__EVENTVALIDATION":eventvalidation,"}
r = requests.post(url, proxies, auth, data )
print r
Run Code Online (Sandbox Code Playgroud)
这个代码在我使用时工作正常requests.get(url, proxies=proxies, auth=auth),但是当有一些数据必须通过requests.post()代理身份验证发送时该怎么办?
我写了一个webhook来集成到chat(slack/mattermost api)中.
启动和运行的最简单方法是一个快速的PHP脚本,如下所示:
<?php
$token = $_POST["token"];
$arg = $_POST["text"];
$output = exec("./webhook_script.sh {$token} {$arg}");
Run Code Online (Sandbox Code Playgroud)
目前,脚本工作正常,但我担心有人可以恶意地执行http POST,其中查询参数text(脚本:) $arg具有某种注入攻击.
例: http://myserver/webhook.php?token=abc&text=123;rm -rf *
因此$arg变得123; rm -rf和exec命令执行恶意rm -rf *
这与我熟悉的"sql注入"本质上类似,但我不确定如何使bash脚本安全...
是以某种方式引用参数,或者使用a regex来检查脚本参数是一件简单的事情吗?