Ejemplo n.º 1
0
Archivo: api.php Proyecto: R-J/hm3
 /**
  * Setup optional post properties
  * @param resource $ch curl connection
  * @param array $post post fields
  * @return void
  */
 private function curl_setopt_post($ch, $post)
 {
     if (!empty($post)) {
         Hm_Functions::c_setopt($ch, CURLOPT_POST, true);
         Hm_Functions::c_setopt($ch, CURLOPT_POSTFIELDS, $this->format_post_data($post));
     }
 }
Ejemplo n.º 2
0
 /**
  * post to an oauth2 endpoint
  * @param string $url url to post to
  * @param array $flds post data
  * @return array
  */
 private function curl_post($url, $flds)
 {
     $result = array();
     $ch = Hm_Functions::c_init();
     Hm_Functions::c_setopt($ch, CURLOPT_URL, $url);
     Hm_Functions::c_setopt($ch, CURLOPT_POST, 5);
     Hm_Functions::c_setopt($ch, CURLOPT_POSTFIELDS, $flds);
     Hm_Functions::c_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     Hm_Functions::c_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
     $curl_result = Hm_Functions::c_exec($ch);
     if (substr($curl_result, 0, 1) == '{') {
         $result = @json_decode($curl_result, true);
     }
     return $result;
 }
Ejemplo n.º 3
0
 public function process()
 {
     if (Hm_Page_Cache::get('nux_dev_news')) {
         $this->out('nux_dev_news', Hm_Page_Cache::get('nux_dev_news'));
         return;
     }
     $ch = Hm_Functions::c_init();
     $res = array();
     Hm_Functions::c_setopt($ch, CURLOPT_URL, 'http://cypht.org/git.txt');
     Hm_Functions::c_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $curl_result = Hm_Functions::c_exec($ch);
     if (trim($curl_result)) {
         foreach (explode("\n", $curl_result) as $line) {
             if (preg_match("/^([a-z0-9]{40})\\|([a-z0-9]{7})\\|([^\\|]+)\\|([^\\|]+)\\|([^\\|]+)\$/", $line, $matches)) {
                 $res[] = array('hash' => $matches[1], 'shash' => $matches[2], 'name' => $matches[3], 'age' => date('D, M d', strtotime($matches[4])), 'note' => $matches[5]);
             }
         }
     }
     Hm_Page_Cache::add('nux_dev_news', $res);
     $this->out('nux_dev_news', $res);
 }