コード例 #1
0
ファイル: api.php プロジェクト: R-J/hm3
 /**
  * Process a curl request result
  * @param resource $ch curl connection
  * @return array
  */
 private function curl_result($ch)
 {
     $curl_result = Hm_Functions::c_exec($ch);
     $result = @json_decode($curl_result, true);
     if ($result === NULL) {
         return array();
     }
     return $result;
 }
コード例 #2
0
ファイル: oauth2.php プロジェクト: GordonDiggs/hm3
 /**
  * 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;
 }
コード例 #3
0
ファイル: modules.php プロジェクト: GordonDiggs/hm3
 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);
 }