first commit
This commit is contained in:
48
autoload/curl.class.php
Normal file
48
autoload/curl.class.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// ------------------------------------------------
|
||||
// This is a cURL Object
|
||||
// Created by: Gilberto C.
|
||||
// InteractiveUtopia.com
|
||||
// ------------------------------------------------
|
||||
|
||||
class CurlServer
|
||||
{
|
||||
private $access_token;
|
||||
|
||||
function __construct( $token )
|
||||
{
|
||||
$this->access_token = $token;
|
||||
}
|
||||
|
||||
function post_request($url, $submitJson, $debug = false )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $submitJson);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->access_token, 'Content-Type: application/json'));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$serverReponseObject = json_decode($server_output);
|
||||
|
||||
// Debug
|
||||
if ( $debug )
|
||||
print_r($serverReponseObject);
|
||||
}
|
||||
function get_request($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->access_token));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$serverReponseObject = json_decode($server_output);
|
||||
|
||||
// Debug
|
||||
//print_r ( $server_output );
|
||||
print_r($serverReponseObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user