SHARE
TWEET

Untitled

a guest Sep 11th, 2019 161 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     $proxy_username = 'sp2eb32f97';
  4.     $proxy_password = 'Thrust66442';
  5.  
  6.     function UserAuthentication($username,$password)
  7.     {
  8.         $url = 'https://api.smartproxy.com/v1/auth';
  9.  
  10.         $curl = curl_init();
  11.  
  12.         $auth = base64_encode($username . ':' . $password);
  13.  
  14.         curl_setopt($curl, CURLOPT_URL,$url);
  15.         curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
  16.         curl_setopt($curl, CURLOPT_CUSTOMREQUEST,"POST");
  17.  
  18.         $headers = array();
  19.         $headers[] = "Accept: application/json";
  20.         $headers[] = "Authorization: Basic $auth";
  21.         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  22.  
  23.         $response = curl_exec($curl);
  24.  
  25.         $response = json_decode($response,true);
  26.  
  27.         curl_close($curl);
  28.  
  29.         return $response;
  30.     }
  31.  
  32.     function AddWhitelistedIP($data)
  33.     {
  34.         global $proxy_username;
  35.         global $proxy_password;
  36.  
  37.         $auth = UserAuthentication($proxy_username,$proxy_password);
  38.  
  39.         $token = $auth['token'];
  40.  
  41.         $userId = $auth['user_id'];
  42.  
  43.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/whitelisted-ips';
  44.         $payload = json_encode($data);
  45.         $ch = curl_init();
  46.         curl_setopt($ch, CURLOPT_URL, $url);
  47.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  48.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  49.         $headers = array();
  50.         $headers[] = "Accept: application/json";
  51.         $headers[] = "Content-Type: application/json";
  52.         $headers[] = "Authorization: Token $token";
  53.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  54.         curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  55.         $result = curl_exec($ch);
  56.         curl_close($ch);
  57.         echo $result;
  58.     }
  59.  
  60.     function RemoveWhitelistedIP($id)
  61.     {
  62.         global $proxy_username;
  63.         global $proxy_password;
  64.  
  65.         $auth = UserAuthentication($proxy_username,$proxy_password);
  66.  
  67.         $token = $auth['token'];
  68.  
  69.         $userId = $auth['user_id'];
  70.  
  71.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/whitelisted-ips/' . $id;
  72.  
  73.         $ch = curl_init();
  74.         curl_setopt($ch, CURLOPT_URL, $url);
  75.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  76.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
  77.  
  78.         $headers = array();
  79.         $headers[] = "Accept: application/json";
  80.         $headers[] = "Authorization: Token '$token'";
  81.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  82.         $result = curl_exec($ch);
  83.         curl_close($ch);
  84.         echo $result;
  85.     }
  86.  
  87.     function CreateSubUser($username,$password,$traffic_limit,$service_type = 'residential_proxies')
  88.     {
  89.         global $proxy_username;
  90.         global $proxy_password;
  91.  
  92.         $auth = UserAuthentication($proxy_username,$proxy_password);
  93.  
  94.         $token = $auth['token'];
  95.  
  96.         $userId = $auth['user_id'];
  97.        
  98.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/sub-users';
  99.  
  100.         $data = array(
  101.             "username" => $username,
  102.             "password" => $password,
  103.             "traffic_limit" => $traffic_limit, // Can be float
  104.             "service_type" => $service_type // Possible values: residential_proxies, shared_proxies
  105.         );
  106.  
  107.         $payload = json_encode($data);
  108.         $ch = curl_init();
  109.         curl_setopt($ch, CURLOPT_URL, $url);
  110.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  111.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  112.  
  113.         $headers = array();
  114.         $headers[] = "Accept: application/json";
  115.         $headers[] = "Content-Type: application/json";
  116.         $headers[] = "Authorization: Token '$token'";
  117.  
  118.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  119.         curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  120.         $result = curl_exec($ch);
  121.  
  122.         if(curl_errno($ch))
  123.         {
  124.             echo "Error: " . curl_error($ch);
  125.         }
  126.  
  127.         curl_close($ch);
  128.         echo $result;
  129.  
  130.         return $result;
  131.     }
  132.  
  133.     function DeleteSubUser($targetId)
  134.     {
  135.         global $proxy_username;
  136.         global $proxy_password;
  137.  
  138.         $auth = UserAuthentication($proxy_username,$proxy_password);
  139.  
  140.         $token = $auth['token'];
  141.  
  142.         $userId = $auth['user_id'];
  143.  
  144.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/sub-users/' . $targetId;
  145.         $ch = curl_init();
  146.         curl_setopt($ch, CURLOPT_URL, $url);
  147.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  148.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
  149.  
  150.         $headers = array();
  151.         $headers[] = "Accept: application/json";
  152.         $headers[] = "Authorization: Token $token";
  153.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  154.         $result = curl_exec($ch);
  155.         curl_close($ch);
  156.         echo $result;
  157.     }
  158.  
  159.     function GetEndpoint()
  160.     {
  161.         global $proxy_username;
  162.         global $proxy_password;
  163.  
  164.         $auth = UserAuthentication($proxy_username,$proxy_password);
  165.  
  166.         $token = $auth['token'];
  167.  
  168.         $userId = $auth['user_id'];
  169.  
  170.         $url = 'https://api.smartproxy.com/v1/endpoints';
  171.         $ch = curl_init();
  172.         curl_setopt($ch, CURLOPT_URL, $url);
  173.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  174.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  175.         $headers = array();
  176.         $headers[] = "Accept: application/json";
  177.         $headers[] = "Authorization: Token $token";
  178.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  179.         $result = curl_exec($ch);
  180.         curl_close($ch);
  181.         echo $result;
  182.     }
  183.  
  184.     function GetEndpointByType($type)
  185.     {
  186.         global $proxy_username;
  187.         global $proxy_password;
  188.  
  189.         $auth = UserAuthentication($proxy_username,$proxy_password);
  190.  
  191.         $token = $auth['token'];
  192.  
  193.         $userId = $auth['user_id'];
  194.  
  195.         $url = 'https://api.smartproxy.com/v1/endpoints/' . $type;
  196.         $ch = curl_init();
  197.         curl_setopt($ch, CURLOPT_URL, $url);
  198.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  199.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  200.         $headers = array();
  201.         $headers[] = "Accept: application/json";
  202.         $headers[] = "Authorization: Token $token";
  203.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  204.         $result = curl_exec($ch);
  205.         curl_close($ch);
  206.         echo $result;
  207.     }
  208.  
  209.     function GetSubscriptions()
  210.     {
  211.         global $proxy_username;
  212.         global $proxy_password;
  213.  
  214.         $auth = UserAuthentication($proxy_username,$proxy_password);
  215.  
  216.         $token = $auth['token'];
  217.  
  218.         $userId = $auth['user_id'];
  219.  
  220.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/subscriptions';
  221.         $ch = curl_init();
  222.         curl_setopt($ch, CURLOPT_URL, $url);
  223.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  224.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  225.         $headers = array();
  226.         $headers[] = "Accept: application/json";
  227.         $headers[] = "Authorization: Token $token";
  228.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  229.         $result = curl_exec($ch);
  230.         curl_close($ch);
  231.         echo $result;
  232.     }
  233.  
  234.     function GetSubuserTraffic($from,$to,$date)
  235.     {
  236.         global $proxy_username;
  237.         global $proxy_password;
  238.  
  239.         $auth = UserAuthentication($proxy_username,$proxy_password);
  240.  
  241.         $token = $auth['token'];
  242.  
  243.         $userId = $auth['user_id'];
  244.  
  245.         $query = array(
  246.             'type' => $from, // Available types: 24h, month, 7days, custom. If custom type is selected you must provide $from and $to parameters
  247.             'from' => $date, //yyyy-mm-dd
  248.             'to' => $to
  249.           );
  250.  
  251.           $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/sub-users/' . $username . '/traffic?' . http_build_query($query, '', "&");
  252.           $ch = curl_init();
  253.           curl_setopt($ch, CURLOPT_URL, $url);
  254.           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  255.           curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  256.           $headers = array();
  257.           $headers[] = "Accept: application/json";
  258.           $headers[] = "Authorization: Token $token";
  259.           curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  260.           $result = curl_exec($ch);
  261.           curl_close($ch);
  262.           echo $result;
  263.     }
  264.  
  265.     function GetSubusers()
  266.     {
  267.         global $proxy_username;
  268.         global $proxy_password;
  269.  
  270.         $auth = UserAuthentication($proxy_username,$proxy_password);
  271.  
  272.         $token = $auth['token'];
  273.  
  274.         $userId = $auth['user_id'];
  275.  
  276.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/sub-users';
  277.         $ch = curl_init();
  278.         curl_setopt($ch, CURLOPT_URL, $url);
  279.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  280.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  281.         $headers = array();
  282.         $headers[] = "Accept: application/json";
  283.         $headers[] = "Authorization: Token $token";
  284.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  285.         $result = curl_exec($ch);
  286.         curl_close($ch);
  287.         echo $result;
  288.     }
  289.  
  290.     function GetWhitelistedIPs()
  291.     {
  292.         global $proxy_username;
  293.         global $proxy_password;
  294.  
  295.         $auth = UserAuthentication($proxy_username,$proxy_password);
  296.  
  297.         $token = $auth['token'];
  298.  
  299.         $userId = $auth['user_id'];
  300.  
  301.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/whitelisted-ips';
  302.         $ch = curl_init();
  303.         curl_setopt($ch, CURLOPT_URL, $url);
  304.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  305.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  306.         $headers = array();
  307.         $headers[] = "Accept: application/json";
  308.         $headers[] = "Authorization: Token $token";
  309.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  310.         $result = curl_exec($ch);
  311.         curl_close($ch);
  312.         echo $result;
  313.     }
  314.  
  315.     function UpdateSubuser($subuserId)
  316.     {
  317.         global $proxy_username;
  318.         global $proxy_password;
  319.  
  320.         $auth = UserAuthentication($proxy_username,$proxy_password);
  321.  
  322.         $token = $auth['token'];
  323.  
  324.         $userId = $auth['user_id'];
  325.  
  326.         $url = 'https://api.smartproxy.com/v1/users/' . $userId . '/sub-users/' . $subuserId;
  327.  
  328.         $data = array(
  329.         "password" => "",
  330.         "traffic_limit" => 0 // Optional parameter
  331.         );
  332.  
  333.         $payload = json_encode($data);
  334.         $ch = curl_init();
  335.         curl_setopt($ch, CURLOPT_URL, $url);
  336.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  337.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  338.         $headers = array();
  339.         $headers[] = "Accept: application/json";
  340.         $headers[] = "Content-Type: application/json";
  341.         $headers[] = "Authorization: Token $token";
  342.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  343.         curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  344.         $result = curl_exec($ch);
  345.         curl_close($ch);
  346.         echo $result;
  347.     }
  348. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top