Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace dibdibs;
- class get{
- private $URL;
- function __construct($params){
- $this->URL - $params['url'];
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $URL);
- }
- }
- class post{
- private static $URL;
- private static $data;
- public static $token = "33225A179D9A4E1BDA73C012C1C3CBAB8BD00326883BDBEB6FA682482E40F68D";
- public function __construct($params){
- self::$URL = $params['url'];
- self::$data = $params['data'];
- }
- public function json(){
- $c = curl_init(self::$URL);
- curl_setopt($c, CURLOPT_HEADER, FALSE);
- curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
- curl_setopt($c, CURLOPT_POST, TRUE);
- curl_setopt($c, CURLOPT_POSTFIELDS, json_encode(self::$data));
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($c, CURLOPT_USERAGENT, 'User-Agent: curl/7.39.0');
- $jsResp = curl_exec($c);
- curl_close($c);
- return get_object_vars(json_decode($jsResp));
- }
- public function http(){
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'POST',
- 'content' => http_build_query(self::$data)
- )
- );
- $cntxt = stream_context_create($options);
- $result = file_get_contents(self::$URL, false, $cntxt);
- return $result;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement