我有一个脚本,用于检查测试的netflix帐户是否有效。 出于某种原因,它只是拒绝工作我不知道我做错了什么。
Checker Page的PHP编辑: 添加了if语句,因此它不会发布空白只是转到页面:
<?php
if(isset($_POST['e']) && isset($_POST['p'])){
$e = @$_POST['e'];
$p = @$_POST['p'];
$URL = 'MyAPI.php?e='.$e.'&p='.$p;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$page = curl_exec($ch);
$haystack = $page;
$needle = 'profilesGateWrapper';
if(strpos($needle, $haystack) !== true) {
file_put_contents('working.txt','test', FILE_APPEND);
} else {
echo $page;
}
}
?>
MyAPI.php:
<?php
$email=$_GET['e'];
$pass=$_GET['p'];
$url='https://signup.netflix.com/Login'; //httpS
$cookie="cookie.txt";
$ch2 = curl_init();
curl_setopt ($ch2, CURLOPT_URL, $url);
curl_setopt ($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31");
curl_setopt ($ch2, CURLOPT_TIMEOUT, 60);
curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch2, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch2, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch2, CURLOPT_REFERER, $url);
$result2 = curl_exec ($ch2);
curl_close($ch2);
$expA=explode('name="authURL" value="',$result2);
$expB=explode('"/>',$expA[1]);
$auth=$expB[0];
//$postdata = "email=".urlencode($email)."&password=".$pass."&authURL=".urlencode($auth).'&RememberMe=false';
$postdata = http_build_query( array('email' => urlencode($email), 'password' => $pass, 'authURL' => urlencode($auth)));
$postdata = http_build_query( array('email' => $email, 'password' => $pass, 'authURL' => $auth, 'RememberMe' => ''));
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
?>
我已尝试过strpos的所有组合!==和===等以及true和falses,但都没有效果。
为什么查找profilesGateWrapper是因为您只在登录时在HTML中看到它。
当我输入var_dump($ page);在$ page之后输入一封电子邮件并通过它,当你登录时显示我的页面,所以cURL没有问题。
我的目标是基本确定您是否已登录,如果您已登录,则将file:password_content中的电子邮件:密码与:在它们之间转换为working.txt文件,然后如果找不到则声明,然后执行电子邮件:传入invalid.txt。但这对我不起作用我已经在这约2个小时了,请有人帮忙。
答案 0 :(得分:0)
我认为你想要做的是
if(strpos($needle, $haystack) !== false) { // this means not found
echo $page;
} else { // this means strpos returns integer (the position of occurrence)
file_put_contents('working.txt','test', FILE_APPEND);
}
strpos不会返回true
。