如何使用curl post形式在登录链接中编写内容

时间:2019-05-13 17:36:58

标签: curl post

我尝试使用post方法保存内容以打开端口链接textaria文件,但我有一些代码无法正常工作 我已经尝试过该代码,但无法正常工作。

<?php
$url = 'http://admin:admin@vc.cline.pk:8888/files.html';
$body = "file=oscam.user&filecontent=my+content&action=Save";
function get_data($url, $body)
{
//$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
    $ch      = curl_init();
    $timeout = 7;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    //curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    //curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
?>

0 个答案:

没有答案