- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我需要使用 http_build_query 创建一个 POST 请求。以下是我的代码:
$uri_args = array (
'name' => 'Jack',
'surname' => 'Jackson',
'username' => 'jackson12',
'email' => 'Jack@mail.com',
);
$uri = http_build_query($uri_args);
header("Location: http://samplesite.com?$uri");
目前它生成一个类似 GET 的请求,但我需要 POST。考虑到我不想使用 curl,...仅使用 http_build_query。
最佳答案
<?php
$data = array(
'name' => 'Jack',
'surname' => 'Jackson',
'username' => 'jackson12',
'email' => 'Jack@mail.com',
);
$query = http_build_query($data);
// create context
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL,
'content' => $query,
),
));
// send request and collect data
$response = file_get_contents(
$target = "http://example.com/target.php",
$use_include_path = false,
$context);
//some actions with $response
//...
// redirect
header("Location: http://samplesite.com");
关于php - POST 请求仅在 php 中使用 http_build_query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17826912/
我有一个 URL,它通过 http_build_query 函数变成了一个查询字符串。 但是我有一个无法编辑的参数timestamp。而 × 变成乘号 x。 有解决办法吗? 这是我传递给 http_b
我想使用 http_build_query 构建这个 url: https://www.googleapis.com/freebase/v1/topic/m/0d6lp?filter=/common/
请检查以下数组: Array([bunrey] => Array ([0] => 20130730181908615391000000) [mt.shasta] => Array (
有没有办法使用同名参数通过 http_build_query 自动构建查询? 如果我做类似的事情 array('foo' => 'x', 'foo' => 'y'); 它们显然在数组中被覆盖了,但即使
您好,我正在使用此代码发布 url 并获取结果,但它在每个结果之前添加 =0 我的代码是 In this demonstration: >tts is done on server si
我需要使用 HttpWebRequest 将一些数据从我的 C# 客户端传递到服务器上的 PHP 页面.根据文档的预期数据是一个数组数组,如下所示: $postData = array( 'l
当数组键也是 html-char 代码时,使用 http_build_query() 将数组编码为 URL 会产生奇怪的行为。 例如: return http_build_query([ 'id
我完全是 PHP 的新手,我尝试寻找解决方案,但似乎找不到。 每当我尝试在我的数组上使用 http_build_query() 时,它会将 $note 变量变成一个符号 (¬e)。我只是想知道是否有任
我只是发现这些功能似乎是多余的。http_build_query() 属于标准的php函数。http_build_str() 是 pecl_http 包的一部分。 它们是 100% 冗余的吗? 我专注
我今天遇到了一个问题,我将一个值设置为空数组的键传递给 http_build_query()。例如: $args = array("foo", "bar", array(), "baz"); $qs
为什么在使用 http_build_query 函数构建查询字符串时,它会将方括号 [] urlencode 到值之外,如何摆脱它? $query = array("var" => array("fo
有没有办法使用 http_build_query() 而无需根据某些 RFC 标准对其进行 URL 编码? 为什么我不想对所有内容进行 URL 编码:我正在查询 Ebay API。他们诚实地坚持参数名
这个问题在这里已经有了答案: How do I pass variables and data from PHP to JavaScript? (19 个回答) 关闭 9 年前。 为什么这不起作用?
我需要使用 http_build_query 创建一个 POST 请求。以下是我的代码: $uri_args = array ( 'name' => 'Jack', 'surn
http_build_query($array) 将数组转换成a=1&b=2的格式, 但是如何让它转换成a=1;b=2的格式呢? 那里有原生函数吗? 最佳答案 第三个参数为http_build_que
我有一个包含我的数据的 map ,我想用它构建一个查询字符串,就像我在 PHP 上使用 http_build_query 一样。我不确定这段代码是否是它的最佳实现,或者我是否忘记了什么? public
'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext pro
这段代码: $query = array( "var" => "no", "not_var" => "yes", "var2" => "maybe" ); print http
我是一名优秀的程序员,十分优秀!