简体   繁体   English

PHP,cURL发布数组?

[英]PHP, cURL Posting array?

I'm trying to use cURL to login. 我正在尝试使用cURL登录。

The HTML from the login page is doing something I never saw. 登录页面上的HTML正在做我从未见过的事情。

<input type="text" name="user_session[login]"/>
<input type="password" name="user_session[password]"/>

I have tried to: 我试过:

user_session[login]=blablabla&user_session[password]=blablabla

But nothing, any idea? 但没什么,任何想法?

Make sure you URL-encode the keys. 确保对密钥进行URL编码。 I don't think those brackets are safe. 我不认为这些括号是安全的。 PHP will parse those arguments as an array, but what the script does shouldn't matter if you're just trying to simulate a form submission. PHP会将这些参数解析为数组,但如果您只是尝试模拟表单提交,那么脚本的作用应该无关紧要。 If you use the PHP 5 function http_build_query with the array ['user_session' => ['login' => 'NAME', 'password' => 'PASS']] it should return the query string you need, properly escaped (which can be appended to the URL after ? or used as POST data with curl_setopt($resource, CURL_POSTFIELDS, http_build_query($args)) ). 如果您使用PHP 5函数http_build_query与数组['user_session' => ['login' => 'NAME', 'password' => 'PASS']]它应该返回您需要的查询字符串,正确转义(可以在?之后附加到URL,或者用作curl_setopt($resource, CURL_POSTFIELDS, http_build_query($args)) )的POST数据。

If it still doesn't work, post the whole form; 如果仍然不起作用,请张贴整个表格; there may be some other problem with your submission besides the brackets. 除括号外,您的提交可能还有其他问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM