Advertisement
villers

Untitled

May 27th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1.     /**
  2.     * _apiCall
  3.     *
  4.     * @access private
  5.     * @access string  $path
  6.     * @param  array   $get_args
  7.     * @return mixed
  8.     */
  9.     private function _apiCall($path, $get_args = array()) {
  10.         $get_string        = '';
  11.  
  12.         if (!$get_args) {
  13.             $get_args = array();
  14.         }
  15.  
  16.         $get_args['key'] = $this->getApiKey();
  17.  
  18.         foreach ($get_args as $key => $val) {
  19.             $get_string .= '&'.$key.'='.rawurlencode($val);
  20.         }
  21.  
  22.         $relative_url = $path.(strlen($get_string) ? '?'.trim($get_string, '&') : '');
  23.  
  24.         $response = @file_get_contents($this->getApiUrl().$relative_url);
  25.  
  26.         $data = json_decode($response, true);
  27.         if ($data && is_array($data)) {
  28.             if (isset($data['success']) && $data['success'] == false && isset($data['error'])) {
  29.                 error_log('Elophant API Error: '.$data['error']);
  30.             } else {
  31.                 return $data;
  32.             }
  33.         } else {
  34.             return $response;
  35.         }
  36.         return false;
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement