1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| if ((filter_input(INPUT_POST, $_POST['EsendexOriginator'])) && (filter_input(INPUT_POST, $_POST['EsendexRecipient'])))
{
$postfields = array();
$postfields["action"] = "submit";
$postfields["Username"] = "nom";
$postfields["Password"] = "nom1";
$postfields["Account"] = "nom2";
$postfields["FailurePage"] = "url1";
$postfields["SuccessPage"] = "url2";
$postfields["Originator"] = $_POST['EsendexOriginator'];
$postfields["Recipient"] = $_POST['EsendexRecipient'];
$url = "https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx";
$useragent = "Mozilla/5.0";
$referer = $url;
//Initialise une session CURL
$ch = curl_init($url);
//CURL options
curl_setopt($ch, CURLOPT_POST, 1);
//On poste les données du tableau $postfields
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
//On définit un useragent ici Mozilla/5.0
//souvent les bots se font passés pour googlebot ce qui finalement est stupide
//On passe donc un useragent banal
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
//On passe un referrer ici on passe la même page $url
curl_setopt($ch, CURLOPT_REFERER, $referer);
//on récupère le contenu de la page de résultat de la soumission dans une chaine
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// en cas de redirection (facultatif ici)
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//Page de résultats et fermeture de session
$result = curl_exec($ch);
curl_close($ch);
} |
Partager