[英]How to get the content of a HTTPS post request on the server side?
I have a C client which use libcurl to send xml packet to Apache server via HTTPS. 我有一个C客户端,它使用libcurl通过HTTPS将xml数据包发送到Apache服务器。
some parts of the client code as: 客户端代码的某些部分为:
curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/test.php");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, send_buf);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(send_buf));
curl_easy_setopt(curl, CURLOPT_POST, 1L);
res = curl_easy_perform(curl);
The content of send_buf is sent to https apache server ( https://example.com/test.php ), but on the Apache server side, how can I use test.php to get the content of send_buf? send_buf的内容发送到https apache服务器( https://example.com/test.php ),但是在Apache服务器端,如何使用test.php获取send_buf的内容? Any other scripts are welcome.
任何其他脚本都欢迎。 thanks
谢谢
Any example codes? 任何示例代码?
I may be a little unclear on your question, but I'm assuming send_buf is in the standard format, ie, 我对您的问题可能不太清楚,但我假设send_buf为标准格式,即
foo=bar&baz=boo&x=17+cats+etc foo = bar&baz = boo&x = 17 + cats + etc
In that case, in your receiving PHP script (test.php) the $_POST variable will be initialized as follows: 在这种情况下,在您接收的PHP脚本(test.php)中,$ _POST变量将如下初始化:
$_POST['foo'] = "bar"
$_POST['baz'] = "boo"
$_POST['x'] = "17 cats etc"
So you can access a value by using $_POST['foo']. 因此,您可以使用$ _POST ['foo']访问值。
Hope that helps. 希望能有所帮助。
To get everything that is sent (POST) to your Apache server via your test.php file, you can use: 要获取通过test.php文件发送(POST)到Apache服务器的所有内容,可以使用:
<?php
var_dump($_POST);
?>
You could also use $_GET if you wanted to get everything passed in the URL (like: https://example.com/test.php?myvar=value ). 如果您想让所有内容都通过URL传递,也可以使用$ _GET(例如: https : //example.com/test.php?myvar=value )。 Finally, $_REQUEST contains both $_POST and $_GET.
最后,$ _ REQUEST包含$ _POST和$ _GET。
If you post a variable called myvar
via your C code, you can retrieve the value in your test.php file with: 如果通过C代码发布了名为
myvar
的变量,则可以使用以下方法在test.php文件中检索值:
<?php
print $_POST['myvar'];
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.