Advertisement
DibDibsTH13TEEN

postget.php

Jul 23rd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. namespace dibdibs;
  3.  
  4. class get{
  5.     private $URL;
  6.    
  7.     function __construct($params){
  8.         $this->URL - $params['url'];
  9.        
  10.         $curl = curl_init();
  11.        
  12.         curl_setopt($curl, CURLOPT_URL, $URL);
  13.     }
  14. }
  15.  
  16. class post{
  17.    
  18.     private static $URL;
  19.     private static $data;
  20.     public static $token = "33225A179D9A4E1BDA73C012C1C3CBAB8BD00326883BDBEB6FA682482E40F68D";
  21.    
  22.     public function __construct($params){
  23.         self::$URL = $params['url'];
  24.         self::$data = $params['data'];
  25.     }
  26.    
  27.     public function json(){
  28.         $c = curl_init(self::$URL);
  29.         curl_setopt($c, CURLOPT_HEADER, FALSE);
  30.         curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
  31.         curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
  32.         curl_setopt($c, CURLOPT_POST, TRUE);
  33.         curl_setopt($c, CURLOPT_POSTFIELDS, json_encode(self::$data));
  34.         curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
  35.         curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE);
  36.         curl_setopt($c, CURLOPT_USERAGENT, 'User-Agent: curl/7.39.0');
  37.        
  38.         $jsResp = curl_exec($c);
  39.        
  40.         curl_close($c);
  41.        
  42.         return get_object_vars(json_decode($jsResp));
  43.     }
  44.    
  45.     public function http(){
  46.         $options = array(
  47.             'http' => array(
  48.                 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
  49.                 'method' => 'POST',
  50.                 'content' => http_build_query(self::$data)
  51.             )
  52.         );
  53.        
  54.         $cntxt = stream_context_create($options);
  55.         $result = file_get_contents(self::$URL, false, $cntxt);
  56.        
  57.         return $result;
  58.     }
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement