I was just doing curl requests with Facebook I have faced a problem if I can just cross that problem I can continue everything easily.
My curl code
function curl($url, $data=null, $ua=null, $cookie=null){
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
if($data != null){
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
if($cookie != null){
curl_setopt($c, CURLOPT_COOKIE, $cookie);
}
if($ua != null){
curl_setopt($c, CURLOPT_USERAGENT, $ua);
}
$hmm = curl_exec($c);
curl_close($c);
return $hmm;
}
$ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0';
$data = curl('https://facebook.com/', 0, $ua, 0,); //$data stores the html response of Facebook.com
print_r($data);
So from this code we get the html response of facebook.com my problem where I got stuck was getting some values from the html response I need to get the values input fields You can see the view source here :- view-source:https://www.facebook.com So please help me to get the values of input fields from first form (form id="login_form" action="https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=111" method="post" novalidate="1" onsubmit="") Example :- I need to get from this field (input type="hidden" name="jazoest" value="2691" autocomplete="off" /) name and value so I need to echo jazoest,2691 and other input fields like this I have tried the preg_match it is not working as expected and I have an example with Dom does same thing
Use this code with the curl function
$ua = 'Mozilla/4.0 (compatible; MSIE 5.0; S60/3.0 NokiaN73-1/2.0(2.0617.0.0.7) Profile/MIDP-2.0 Configuration/CLDC-1.1)';
$data = curl('https://m.facebook.com/', 0, $ua, 0,); //$data stores the html response of Facebook.com
print_r($data);
This is the mobile web url of Facebook and useragent used here from this with help of Dom we can get the input fields with the code below
function parse_inputs($html) {
$dom = new DOMDocument;
@$dom->loadxml($html);
$inputs = $dom->getElementsByTagName('input');
return($inputs);
}
$inputs = parse_inputs($data);
$post_params = "";
foreach ($inputs as $input) {
$post_params .= $input->getAttribute('name') . '=' . urlencode($input->getAttribute('value')) . '&';
}
print_r($post_params);
From this code I can get the input fields for m.facebook.com but not for www.facebook.com please help me with this and another useful example is here please check this also :- https://github.com/jerry-riady/Script-auto-like-face/blob/master/update.php Thanks in advance for all answers.