예제 #1
0
파일: jssdk.php 프로젝트: ptphp/ptphp
 public function media_get($media_id)
 {
     $access_token = $this->getAccessToken();
     Logger::debug($access_token);
     $url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={$access_token}&media_id=" . $media_id;
     $res = $this->httpGet($url);
     $file_path = "media/wechat/" . date("Ymdhis") . rand(10, 99) . rand(100, 999) . rand(1000, 9999) . ".jpg";
     Model_Tools_Qiniu::upload_content($res, $file_path);
     $url = "http://" . PtConfig::$qiniu['domain'] . "/" . $file_path;
     Logger::debug($url);
     return $url;
 }
예제 #2
0
파일: user.php 프로젝트: ptphp/ptphp
 static function get_avatar($url)
 {
     try {
         $content = file_get_contents($url);
         if (!empty($content)) {
             $res = Model_Tools_Qiniu::upload_content($content, "wechat/avatar/" . md5($url));
             $url = Model_Tools_Qiniu::get_res_url($res);
         }
     } catch (Exception $e) {
         self::_error(array(__METHOD__, "get_avatar error", $e->getMessage()));
     }
     return $url;
 }