<?php
/**
 * Created by PhpStorm.
 * User: sunusi
 * Date: 2019-05-05
 * Time: 18:55
 */
function get_web_page($url, $data)
{
    //url-ify the data for the POST
    $fields_string = http_build_query($data);
    //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    $options = array(
        CURLOPT_RETURNTRANSFER => true,   // return web page
        CURLOPT_HEADER => false,  // don't return headers
        CURLOPT_FOLLOWLOCATION => true,   // follow redirects
        CURLOPT_MAXREDIRS => 10,     // stop after 10 redirects
        CURLOPT_ENCODING => "",     // handle compressed
        CURLOPT_USERAGENT => "test", // name of client
        CURLOPT_AUTOREFERER => true,   // set referrer on redirect
        CURLOPT_CONNECTTIMEOUT => 120,    // time-out on connect
        CURLOPT_TIMEOUT => 120,    // time-out on response
        CURLOPT_URL => $url,
        CURLOPT_POST => 1,
        CURLOPT_POSTFIELDS => $fields_string,
    );
    curl_setopt_array($ch, $options);
    //execute post
    $curl_response = curl_exec($ch);
    //echo $curl_response;
    //echo $result;
    //close connection
    curl_close($ch);
    return $curl_response;
}