Example #1
0
 /**
  * @param $call
  * @param array $params
  * @param string $method
  * @return array|null|\stdClass|mixed
  * @throws \RuntimeException
  */
 protected function callApi($call, array $params = array(), $method = self::CALL_GET)
 {
     if (!isset($params['api_user'])) {
         $params['api_user'] = $this->config->getUser();
     }
     if (!isset($params['api_key'])) {
         $params['api_key'] = $this->config->getPass();
     }
     $options = array(\CURLOPT_RETURNTRANSFER => true, \CURLOPT_HEADER => false, \CURLOPT_ENCODING => '', \CURLOPT_SSL_VERIFYPEER => $this->config->getVerifySSL(), \CURLOPT_USERPWD => sprintf('%s:%s', $params['api_user'], $params['api_key']));
     $output = $this->config->getOutput();
     if (substr($call, -1 * strlen($output)) !== $output) {
         $call .= $output;
     }
     $url = $this->config->getBaseUrl() . $call;
     if ($method === self::CALL_GET) {
         $url .= '?' . http_build_query($params);
     } else {
         $options[\CURLOPT_HTTPHEADER] = array('expect:', 'user-agent: evodelavega-sendgrid/1.0;php');
         $options[\CURLOPT_POST] = true;
         $options[\CURLOPT_POSTFIELDS] = $params;
     }
     $ch = $this->initCurl($url, $options);
     //we've set CURL_RETURNTRANSFER, curl_exec returns the result, or false
     $response = curl_exec($ch);
     return $this->processResult($response, $ch);
 }
Example #2
0
 public static function getHTMLBase()
 {
     $base = Config::getBaseUrl();
     $folder = Config::getBaseFolder();
     if (!empty($folder)) {
         $base .= '/' . $folder;
     }
     $base .= '/';
     return $base;
 }
Example #3
0
 public static function url($target, $options = array(), $external = false)
 {
     $values = array();
     $router = Config::$sef ? Lib::router($target) : false;
     $base = $external ? Config::getBaseUrl() . '/' . Config::getBaseFolder() . '/' : '';
     if (!$router) {
         foreach ($options as $k => $v) {
             $values[] = $k . '=' . $v;
         }
         $queries = implode('&', $values);
         if (!empty($queries)) {
             $queries = '?' . $queries;
         }
         return $base . $target . '.php' . $queries;
     }
     $link = $base . $router->build($options);
     return $link;
 }