好的,我想使用cURL创建HTTP_POST到SSL站点.我已经将证书导入了我的服务器.这是我的代码:
$url = "https://www.xxx.xxx";
$post = "";# all data that going to send
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0');
$exe = curl_exec($ch);
$getInfo = curl_getinfo($ch);
if ($exe === false) {
$output = "Error in sending";
if (curl_error($ch)){
$output .= "\n". curl_error($ch);
}
} else if($getInfo['http_code'] != 777){
$output = "No data returned. Error: " . $getInfo['http_code']; …Run Code Online (Sandbox Code Playgroud) 我有一个脚本,需要几秒钟的处理,最多约一分钟.该脚本调整图像数组的大小,锐化它们并最终将它们拉链以供用户下载.
现在我需要某种进度信息.我在想,使用jQuery的.post()方法,来自回调函数的数据会逐步更新,但这似乎不起作用.
在我的例子中,我只是使用循环来模拟我的脚本:
$(document).ready(function() {
$('a.loop').click(function() {
$.post('loop.php', {foo:"bar"},
function(data) {
$("div").html(data);
});
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
loop.php:
for ($i = 0; $i <= 100; $i++) {
echo $i . "<br />";
}
echo "done";
Run Code Online (Sandbox Code Playgroud) 我有一个编辑表单页面来编辑我的网站帖子.它使用post方法到同一页面.如果表单编译正确,则会显示恭喜消息.
问题:
当用户点击刷新按钮时,脚本会尝试再次将数据重新发布到页面.有办法避免这种情况吗?
谢谢
卢卡
我有一个Web服务代理,它使用用户名和密码调用另一个Web服务来验证代理所在站点的用户身份.所有"正常"表单身份验证都由代理处理但是它需要与远程Web服务后面的数据库,用于确定用户是否确实有效.出于安全性/强密码原因,我需要确保以区分大小写的方式将密码传递给远程服务.
目前它正在通过SSL发布http GET,但由于GET使用MVC网址,其中的详细信息并不区分大小写.
如果我将其更改为POST,我会获得区分大小写吗?
好吧,这是交易,我编写了一个应用程序,通过HTTP(post)数据从web url请求,数据使用JSon数组返回,我解析这些数组,以获得我想要的.
直到那里使用Android 2.3.x没有问题但是当我在Android 4中测试它时它根本不起作用.
这是我的代码:
public boolean testConexio(){
boolean status = false;
String rutaServer = "URL.php";
//Log.e("log_tag", "Ruta server: "+rutaServer);
InputStream is = null;
String result = "";
String temporal;
//Valors a demanar/enviar
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("param1",config.getUserDB())); // parametros POST!
nameValuePairs.add(new BasicNameValuePair("param2",config.getPassDB())); // parametros POST!
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(rutaServer);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8")); // valors POST UTF 8 coded <-- I KNOW! this is the way i need them …Run Code Online (Sandbox Code Playgroud) android http-post http-request android-4.0-ice-cream-sandwich
foreach(($_POST["msg"] as $mg) AND ($_POST["control"] as $id))
{
echo $mg;
echo $id;
}
Run Code Online (Sandbox Code Playgroud)
我需要做出类似的东西,任何方式吗?我正在尝试获取10条mysql记录并编辑所有这些记录
我使用此代码将此发送到我的PHP文件.该文件看起来像这样.
file_put_contents('dump.txt', "POST: \n" . print_r($_POST, true) . "\n\n\n GET: \n" . print_r($_GET, true));
Run Code Online (Sandbox Code Playgroud)
我发送这样的json:
public void postData(String url,JSONObject json) {
HttpClient httpclient = new DefaultHttpClient();
String object = "?data=" +json.toString();
System.out.println("object:" + object);
try {
HttpPost httppost = new HttpPost(url.toString());
httppost.setHeader("Content-type", "application/json");
System.out.println("url:" + url.toString());
StringEntity se = new StringEntity(object);
System.out.println("json:" + json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost.setEntity(se);
HttpResponse response = httpclient.execute(httppost);
String temp = EntityUtils.toString(response.getEntity());
System.out.println("response:" + response);
int statusCode = response.getStatusLine().getStatusCode();
System.out.println("Statuscode " + statusCode);
if(statusCode==200) {
Toast.makeText(LbsGeocodingActivity.this, …Run Code Online (Sandbox Code Playgroud) 我目前正在研究PHP中的一些自动化脚本(没有HTML!).我有两个PHP文件.一个是执行脚本,另一个是接收$ _POST数据并返回信息.问题是如何从一个PHP脚本发送POST到另一个PHP脚本,获取返回变量并继续处理第一个没有HTML表单且没有重定向的脚本.我需要在不同的条件下从第一个PHP文件到另一个PHP文件发出几次请求,并根据请求返回不同类型的数据.我有这样的事情:
<?php // action.php (first PHP script)
/*
doing some stuff
*/
$data = sendPost('get_info');// send POST to getinfo.php with attribute ['get_info'] and return data from another file
$mysqli->query("INSERT INTO domains (id, name, address, email)
VALUES('".$data['id']."', '".$data['name']."', '".$data['address']."', '".$data['email']."')") or die(mysqli_error($mysqli));
/*
continue doing some stuff
*/
$data2 = sendPost('what_is_the_time');// send POST to getinfo.php with attribute ['what_is_the_time'] and return time data from another file
sendPost('get_info' or 'what_is_the_time'){
//do post with desired attribute
return $data; }
?>
Run Code Online (Sandbox Code Playgroud)
我想我需要一些将使用属性调用的函数,发送post请求并根据请求返回数据.第二个PHP文件:
<?php // …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Python中查询此API。它似乎以400个代码响应。有人可以告诉我该如何查询该API吗?
在http://text-processing.com/docs/phrases.html中记录了此API。
import requests
r = requests.post('http://text-processing.com/api/phrases/',
data= {'text':'This is California.'})
Run Code Online (Sandbox Code Playgroud)
我想我误解了应该在此处发布数据的方式。
我有一个用于将文件上传到AWS s3的Node程序,我需要使用请求标头指定x-amz-tagging。我尝试了一些东西,但是没有用!
function buildRequestHeader() {
return {
'Content-Length': fileBuffer.size,
'Content-Type': mimeType,
'x-amz-acl': 'public-read',
'x-amz-tagging' :{"tag1":'abcd',"tag2":'efgh'}
}
}Run Code Online (Sandbox Code Playgroud)
我已经从AWS文档中看到了一些东西,
PUT object-key?tagging HTTP/1.1
Host: examplebucket.s3.amazonaws.com
Content-Length: length
Content-MD5: pUNXr/BjKK5G2UKExample==
x-amz-date: 20160923T001956Z
Authorization: authorization string
<Tagging>
<TagSet>
<Tag>
<Key>tag1</Key>
<Value>val1</Value>
</Tag>
<Tag>
<Key>tag2</Key>
<Value>val2</Value>
</Tag>
</TagSet>
</Tagging>Run Code Online (Sandbox Code Playgroud)
您能解释一下它是如何工作的吗?