简体   繁体   中英

How to post values and get response in PHP

I want to do e-mail verification using email-checker . I want to post email and id , and I would like to withdraw it from the posted page, whichever answer is BAD or SUCCESS. Posted page is https://email-checker.net/check .

Here is my code:

$curl_connection = curl_init();
curl_setopt($curl_connection, CURLOPT_URL, 'https://www.bulkemailchecker.com/free-email-checker/');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_FRESH_CONNECT,true);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_HEADER, false);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl_connection, CURLOPT_POST, true);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$data=curl_exec($curl_connection);

Can anyone help me?

first make a GET request to the url, in the headers you will receive a cookie session id, and in the html you will receive a CSRF token called _csrf , save both, and make a new request to https://email-checker.net/check with both the cookie session and the csrf token, and the email, in the parameter (aptly) named email , using a HTTP POST request, with the application/x-www-urlencoded encoding. now your answer will be in the text content of the element in the html you receive with the id results-wrapper .

example implementation using hhb_curl :

<?php
declare(strict_types = 1);
const EMAIL = 'webmaster@hotmail.com';
require_once ('hhb_.inc.php');
$hc = new hhb_curl ( '', true );
$html = $hc->exec ( 'https://email-checker.net' )->getStdOut ();
$domd = @DOMDocument::loadHTML ( $html );
$xp = new DOMXPath ( $domd );
$csrf_token = $xp->query ( '//input[@name="_csrf"]' )->item ( 0 )->getAttribute ( "value" );
$html = $hc->setopt_array ( array (
        CURLOPT_URL => 'https://email-checker.net/check',
        CURLOPT_POST => 1,
        CURLOPT_POSTFIELDS => http_build_query ( array (
                '_csrf' => $csrf_token,
                'email' => EMAIL 
        ) ) 
) )->exec ()->getStdOut ();
$domd = @DOMDocument::loadHTML ( $html );
$xp = new DOMXPath ( $domd );
$result = trim ( $xp->query ( '//*[@id="results-wrapper"]' )->item ( 0 )->textContent );
var_dump ( $result );

currently outputs: string(30) "OK The email address is valid." - meaning that webmaster@hotmail.com is valid. (see line 3)

  • warning, after 5 attempts in less than an hour, you'll get the output Limit Exceeded Only 5 lookups per hour is allowed. Try Premium Plan Limit Exceeded Only 5 lookups per hour is allowed. Try Premium Plan instead

  • warning, the results seem highly unreliable. if you actually need to validate an email address for something, send a verification url to the email instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM