Exemple #1
0
 public function search($arg)
 {
     if (is_string($arg)) {
         $arg['q'] = $arg;
     }
     // http://ils-server:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on
     $this->_curl_exec($this->_host . '/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on');
     radix::dump($this);
 }
Exemple #2
0
 /**
     @param $a the token passed back from the oAuth Provider, typically $_GET['oauth_token']
 */
 public function getAccessToken($a = null)
 {
     $uri = self::TOKEN_ACCESS_URI;
     $arg = array('client_id' => $this->_oauth_client_id, 'client_secret' => $this->_oauth_client_secret, 'grant_type' => 'authorization_code', 'redirect_uri' => $a['redirect_uri'], 'code' => $a['code']);
     $res = radix_http::get($uri . '?' . http_build_query($arg));
     radix::dump($res);
     $ret = json_decode($res['body'], true);
     return $ret;
 }
Exemple #3
0
 /**
  */
 function fetch($uri, $post = null, $verb = null, $head = null)
 {
     if (empty($post)) {
         $post = array();
     }
     if (empty($verb)) {
         $verb = 'GET';
     }
     if (empty($head)) {
         $head = array('User-Agent' => USER_AGENT);
     }
     try {
         // $ret = $this->_oauth->getAccessToken($uri);
         $this->_oauth->fetch($uri, $post, $verb, $head);
         // radix::dump($this->_oauth->debugInfo);
         // $inf = $this->_oauth->getLastResponseInfo();
         $res = $this->_oauth->getLastResponse();
         return json_decode($res, true);
     } catch (Exception $e) {
         radix::dump($this->_oauth->debugInfo);
     }
 }
Exemple #4
0
 /**
     Send
 */
 public function textSend($a)
 {
     // $api = sprintf('SMS/Messages/%s.json',$sid);
     $r = $this->post('SMS/Messages.json', $a);
     radix::dump($r);
     return $r;
 }
Exemple #5
0
 /**
     Read a Message by UUID
     @return Text Object
 */
 function textRead($id)
 {
     $uri = self::_uri('Message/' . $id);
     $ch = self::_curl_init($uri);
     $ret = self::_curl_exec($ch);
     radix::dump($ret);
     if ($ret['info']['http_code'] == 200 && $ret['info']['content_type'] == 'application/json') {
         $ret = json_decode($ret['body'], true);
     }
     return $ret;
 }
Exemple #6
0
 /**
  */
 static function makeThumb($src, $dst, $dst_w, $dst_h)
 {
     list($src_w, $src_h, $type, $attr) = getimagesize($src);
     switch ($type) {
         case IMAGETYPE_GIF:
             $src_i = imagecreatefromgif($src);
             break;
         case IMAGETYPE_JPEG:
             $src_i = imagecreatefromjpeg($src);
             break;
         case IMAGETYPE_PNG:
             $src_i = imagecreatefrompng($src);
             break;
         default:
             throw new \Exception("Invalid Image Type: {$type}", __LINE__);
     }
     imagealphablending($src_i, true);
     //Radix::dump("Source: $src_w x $src_h");
     //Radix::dump("Target: $dst_w x $dst_h");
     // Image Must be Sized to Fit in the $w, $h box
     // if (($src_w > $dst_w) || ($src_h > $dst_h)) {
     $new_size = max($src_w / $dst_w, $src_h / $dst_h);
     //  / max($dst_w,$dst_h);
     //Radix::dump("Scale: $new_size");
     $new_w = min($dst_w, ceil($src_w / $new_size));
     $new_h = min($dst_h, ceil($src_h / $new_size));
     //Radix::dump("Result: $new_w x $new_h");
     // Calculate Centered Location
     $off_x = ($dst_w - $new_w) / 2;
     $off_y = ($dst_h - $new_h) / 2;
     //Radix::dump("Offset: $off_x x $off_y");
     // $dst_i = imagecreatetruecolor($new_w,$new_h);
     $dst_i = imagecreatetruecolor($dst_w, $dst_h);
     // And Make a Transparent Background
     imagealphablending($dst_i, false);
     imagesavealpha($dst_i, true);
     $tbg = imagecolorallocatealpha($dst_i, 255, 255, 255, 127);
     imagefilledrectangle($dst_i, 0, 0, $dst_w, $dst_h, $tbg);
     // Copy & Center
     imagecopyresampled($dst_i, $src_i, $off_x, $off_y, 0, 0, $new_w, $new_h, $src_w, $src_h);
     $ret = imagepng($dst_i, $dst);
     radix::dump($ret);
     imagedestroy($src_i);
     imagedestroy($dst_i);
     if ($ret !== true) {
         $x = error_get_last();
         throw new \Exception($x['message'], __LINE__);
     }
     // }
     return $ret;
 }