gpt4 book ai didi

javascript - cURL 使用 php 发布数据

转载 作者:行者123 更新时间:2023-11-30 19:57:30 25 4
gpt4 key购买 nike

我想展示我的问题,希望找到解决方案我有这个网站来生成 IPTV 帐户 http://iptv.alkaicerteams.com/iptv/index.php此站点包含多个密码,这些密码由上面的短链接随机交换密码通过短链接确认

该站点然后将密码发送到以下链接以生成一个帐户 http://iptv.alkaicerteams.com/iptv/post.php它已经问过头了

POST /iptv/post.php HTTP/1.1
Host: iptv.alkaicerteams.com
Connection: keep-alive
Content-Length: 21
Accept: */*
Origin: http://iptv.alkaicerteams.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
DNT: 1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://iptv.alkaicerteams.com/iptv/index.php
Accept-Encoding: gzip, deflate
Accept-Language: ar,en-US;q=0.9,en;q=0.8
Cookie: PHPSESSID=q4l3hp1h2cvm1amvaq69uund96
user=1120135520184221

回复会是

HTTP/1.1 200 OK
Date: Sat, 15 Dec 2018 03:22:47 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.26
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 89
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

{"status":"success","username":"Kaicer_J7klnKAP","password":"4qu17iCzKC"}

您输入了识别短链接和识别密码的代码 http://iptv.alkaicerteams.com/iptv/index.php然后将数据发送到 http://iptv.alkaicerteams.com/iptv/post.php但是响应来了

POST /iptv/post.php HTTP/1.0
Host: iptv.alkaicerteams.com
Connection: close
Content-Length: 21
Content-type: application/x-www-form-urlencoded

user=2224248965317031
HTTP/1.1 200 OK
Date: Sat, 15 Dec 2018 03:28:44 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.26
Set-Cookie: PHPSESSID=9h8hvbfriusnhn7lcf3ns00g85; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 38
Connection: close
Content-Type: application/json; charset=UTF-8

{"status":"error","message":"invalid"}

我的代码有什么问题

<?php

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://iptv.alkaicerteams.com/iptv/index.php');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$query = curl_exec($curl_handle);
curl_close($curl_handle);
$lines = explode("\n", $query);
$shotline= $lines[257];
$shotline = preg_replace('/\s+/', '', $shotline);

preg_match('/(http:\/\/[^\s]+)/', $shotline, $text);
$solit_shor_url =($text[0]);
$end_short_url = substr($solit_shor_url, 0, 19);

$pass ='';

if ($end_short_url=='http://gsul.me/e4uM') {
$pass ='user=2224248965317031';
} else if ($end_short_url=='http://gsul.me/e4uT') {
$pass ='user=1120135520184221';
}

else if ($end_short_url=='http://gsul.me/e4uX') {
$pass ='user=9999600017456111';
}
else if ($end_short_url=='http://gsul.me/e4v0') {
$pass ='user=9441513141365431';
}
else if ($end_short_url=='http://gsul.me/e4un') {
$pass ='user=3354872122101111';
}
else if ($end_short_url=='http://gsul.me/e4uw') {
$pass ='user=798460044567891';
}
else if ($end_short_url=='http://gsul.me/e4us') {
$pass ='user=7513000478963541';
}
else if ($end_short_url=='http://gsul.me/e4vc') {
$pass ='user=4242421596324581';
}
else if ($end_short_url=='http://gsul.me/e4uo') {
$pass ='user=7531596542584301';
}
else if ($end_short_url=='http://gsul.me/e4uG') {
$pass ='user=5303306289156271';
}

else {
$pass ='erorr';
}

//echo 'url: '.$end_short_url ;
//echo 'pass: '.$pass ;


$url = 'http://iptv.alkaicerteams.com/iptv/post.php';
//$ID = $_GET['id'];
//pass = http://iptv.alkaicerteams.com/iptv/
$data = $pass ;
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
"Origin: http://iptv.alkaicerteams.com",
'method' => 'POST',
'content' => $data,
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);


//$XX= $json_a['username'];
echo $result ;

最佳答案

问题是 PHP 后端在对 /iptv/post.php 的第二次请求中期望用户经过身份验证,即他发送他在第一次请求时获得的身份验证 cookie。为此,您可以使用 CURLOPT_COOKIEJARCURLOPT_COOKIEFILE cURL 选项,并从放置在 /tmp 文件夹中的临时文件中保存/检索 cookie。

您还可以更新代码以不解析 HTML 输出并删除硬编码的 257 行。尽管使用 DOM 寻址 HTML 树的元素会更好,但由于您只需要短 URL,您可以在此处使用 PCRE。

此外,如果没有其他选项可以将这些全部放入配置或数据库的哈希表中,请将您的 if/elseif/else 代码重写为 switch/case。

所以这段代码工作正常:

$cookies = tempnam('/tmp','cookie.txt');

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://iptv.alkaicerteams.com/iptv/index.php');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($curl_handle, CURLOPT_COOKIEFILE, $cookies);
$response = curl_exec($curl_handle);

$matches = [];
preg_match('/\'(http:\/\/gsul\.me\/[a-zA-Z0-9]*?)\'/', $response, $matches);
curl_close($curl_handle);

$end_short_url = $matches[1];

switch($end_short_url) {
case 'http://gsul.me/e4uM':
$pass = 'user=2224248965317031';
break;
case 'http://gsul.me/e4uT':
$pass = 'user=1120135520184221';
break;
case 'http://gsul.me/e4uX':
$pass = 'user=9999600017456111';
break;
case 'http://gsul.me/e4v0':
$pass = 'user=9441513141365431';
break;
case 'http://gsul.me/e4un':
$pass = 'user=3354872122101111';
break;
case 'http://gsul.me/e4uw':
$pass = 'user=798460044567891';
break;
case 'http://gsul.me/e4us':
$pass = 'user=7513000478963541';
break;
case 'http://gsul.me/e4vc':
$pass = 'user=4242421596324581';
break;
case 'http://gsul.me/e4uo':
$pass = 'user=7531596542584301';
break;
case 'http://gsul.me/e4uG':
$pass = 'user=5303306289156271';
break;
default:
$pass ='erorr';
break;
}


$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://iptv.alkaicerteams.com/iptv/post.php');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($curl_handle, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $pass);
$response = curl_exec($curl_handle);
curl_close($curl_handle);

var_dump($response);

关于javascript - cURL 使用 php 发布数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53789305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com