找回用户名,密码通过参数传递卷曲 [英] Retrieve username, password parameters passed through curl

查看:152
本文介绍了找回用户名,密码通过参数传递卷曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送用户名和密码参数,使用curl一个网址,我想找回它们。我的参数发送到一个页面,如下所示:

I am trying to send username and password parameters to a url using curl, and I want to retrieve them. I send the parameters to a page, like the following:

<?php

$curl = curl_init('http://localhost/sample.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);                         
curl_setopt($curl, CURLOPT_USERPWD, 'key:123456');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);                    
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);                          
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);                           
curl_setopt($curl, CURLOPT_USERAGENT, 'Sample Code');

$response = curl_exec($curl);                                          
$resultStatus = curl_getinfo($curl);                                   

if($resultStatus['http_code'] == 200) {
    echo $response;
} else {
    echo 'Call Failed '.print_r($resultStatus);                         
}
?>

现在在sample.php页面,我怎么能找回那些参数?
(在这里,用户名是关键,密码为123456)。

Now in the sample.php page, how can I retrieve those parameters? (here, username is key, password is 123456).

我想他们一定是$ _ SERVER数组中可用,但他们是不可用的。

I suppose they must be available in the $_SERVER array, but they are not available.

推荐答案

默认情况下,袅袅发出HTTP GET请求。在这种情况下,你必须参数追加到您所呼叫的网址:

By default, cURL issues an HTTP GET request. In this case, you'd have to append the parameters to the URL you're calling:

$curl = curl_init('http://localhost/sample.php?foo=bar&baz=zoid');

sample.php $ _ GET ['酒吧'] $ _ GET ['巴兹'] 将分别提供。如果它是一个POST请求,你要发行,则需要通过设置参数 curl_setopt

In sample.php, $_GET['bar'] and $_GET['baz'] would be available respectively. If it's a POST request, you want to issue, you'll need to set the parameters via curl_setopt:

$curl = curl_init('http://localhost/sample.php');
curl_setopt($curl, CURLOPT_POSTFIELDS, 'foo=bar&baz=zoid');

这篇关于找回用户名,密码通过参数传递卷曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆