src/Core.php
/**
     * Sends a GET request to a RESTful API through cURL.
     * 
     * @param string url - the url where the api is located.
     * @param array parameters - optional array of name value pairs for sending to 
     *                           the RESTful API.
     * @param bool arrayForm - optional - set to true to return an array instead of 
     *                                    a stdClass object.
     * 
     * @return stdObject - json response object from the api server
     */
Sends a GET request to a RESTful API through cURL.

@param string url - the url where the api is located.
@param array parameters - optional array of name value pairs for sending to
the RESTful API.
@param bool arrayForm - optional - set to true to return an array instead of
a stdClass object.

@return stdObject - json response object from the api server
Sends a GET request to a RESTful API through cURL . @param string url - the url where the api is located . @param array parameters - optional array of name value pairs for sending to the RESTful API . @param bool arrayForm - optional - set to true to return an array instead of a stdClass object . @return stdObject - json response object from the api server
public static function sendGetRequest($url, array $parameters=array(), $arrayForm=false)
    {
        if (count($parameters) > 0)
        {
            $query_string = http_build_query($parameters, '', '&');
            $url .= $query_string;
        }
        $curl = curl_init();
        $curlOptions = array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => $url,
        );
        curl_setopt_array($curl, $curlOptions);
        $rawResponse = curl_exec($curl);
        curl_close($curl);
        $responseObj = json_decode($rawResponse, $arrayForm); 
        if ($responseObj == null)
        {
            $errMsg = 'Recieved a non json response from API: ' . $rawResponse;
            throw new \Exception($errMsg);
        }
        return $responseObj;
    }
public static function sendGetRequest ( $ url , array $ parameters = array ( ) , $ arrayForm = false ) { if ( count ( $ parameters ) > 0 ) { $ query_string = http_build_query ( $ parameters , '' , '&' ) ; $ url .= $ query_string ; } $ curl = curl_init ( ) ; $ curlOptions = array ( CURLOPT_RETURNTRANSFER => 1 , CURLOPT_URL => $ url , ) ; curl_setopt_array ( $ curl , $ curlOptions ) ; $ rawResponse = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; $ responseObj = json_decode ( $ rawResponse , $ arrayForm ) ; if ( $ responseObj == null ) { $ errMsg = 'Recieved a non json response from API: ' . $ rawResponse ; throw new \ Exception ( $ errMsg ) ; } return $ responseObj ; }
Sends a GET request to a RESTful API through cURL.
Sends a GET request to a RESTful API through cURL .
# Get cURL resource # Set some options - we are passing in a useragent too here # Send the request # Close request to clear up some resources # Convert to json object. # Decode JSON String