예제 #1
0
 public function actionAjaxLogin()
 {
     $name = I('name');
     $pwd = I('psw');
     $pk = I('projkey');
     $isRem = I('rem');
     $curl = new Curl();
     $url = str_replace(array('{host}', '{name}', '{pwd}'), array($this->apiHost, $name, $pwd), $this->WEB_API_LOGIN);
     $rs = $curl->get($url);
     $rs = json_decode($rs, true);
     //注释:这个$rs返回是的当前用户登录日志,如:上一次登录时间
     if (!empty($rs)) {
         if (!empty($rs['errorMessages'])) {
             //echo '登录失败,请重试';
             return $this->ajax_response("0", '账号或密码错误,请重试');
         } else {
             if ($isRem == "1") {
                 cookie('jira_u', $name);
                 cookie('jira_p', md5($pwd));
             }
             cookie('jira_pk', $pk);
             \Yii::$app->session->set('name', $name);
             \Yii::$app->session->set('psw', $pwd);
             $rd_url = U(['issue/index', 'pk' => $pk]);
             return $this->ajax_response("1", $rd_url);
         }
     }
 }
예제 #2
0
파일: HttpSqs.php 프로젝트: gtyd/jira
 /**
  * 获取CURL对象,实现单例
  * @return object \mysoft\http\Curl
  */
 private function _getCurl()
 {
     static $curl;
     //单例对象
     if ($curl) {
         return $curl;
     }
     $curl = new Curl();
     $curl->setOption(CURLOPT_HEADER, true);
     //开启捕获header信息
     $curl->setOption(CURLOPT_VERBOSE, false);
     return $curl;
 }
예제 #3
0
파일: Notice.php 프로젝트: gtyd/jira
 public function mail($subject, $content, $mailto = [])
 {
     $url = "http://120.26.210.193:1218/?name=mail&opt=put";
     $curl = new Curl();
     if ($mailto) {
         $to = $mailto;
     } else {
         $to = $this->mailto;
     }
     if (empty($to)) {
         throw new \Exception('发送对像不允许为空!');
     }
     if (empty($subject)) {
         throw new \Exception('发送主题不为空');
     }
     if (empty($content)) {
         throw new \Exception('发送内容不为空');
     }
     $body = sprintf('%s|%s|%s', implode(',', $to), $subject, $content);
     return $curl->post($url, $body);
 }
예제 #4
0
파일: QyHelper.php 프로젝트: gtyd/jira
 static function syncUser($access_token, $media_id, $url = '', $token = '', $aeskey = '')
 {
     $curl = new Curl();
     if (!empty($url) && !empty($token) && !empty($aeskey)) {
         //此分支是按照协议来的,但是目前为止,没有调通。 by fangl
         $json = json_encode(['media_id' => $media_id, 'callback' => ['url' => $url, 'token' => $token, 'encodingaeskey' => base64_encode($aeskey)]]);
     } else {
         $json = json_encode(['media_id' => $media_id]);
     }
     \Yii::info($json, __METHOD__);
     $ret = $curl->post(str_replace('ACCESS_TOKEN', $access_token, self::SYNC_USER), $json);
     return json_decode($ret, true);
 }
예제 #5
0
파일: Client.php 프로젝트: gtyd/jira
 /**
  * 请求Api
  * @param strign       $http_method , post or get
  * @param string       $url , '/orgcode/demo/site/index'   
  * @param array        $params ,['id'=>1,'type'=>'test' ,...] ,也可以不传,如果参数在url参数上,这里必须传空
  * @param array|string $data post提交数据的时候必须传
  * @return string
  * @throws \Exception
  */
 private function _callApi($http_method, $url, $params = [], $data = [])
 {
     //        $cache_result = $this->_getFromCache($url,$params);
     //        if($cache_result){
     //            return $cache_result;
     //        }
     $curl = new Curl();
     if ($this->curl_options) {
         //设置超时请求
         foreach ($this->curl_options as $key => $val) {
             $curl->setOption($key, $val);
             //设置curl options
         }
     }
     //将签名参数加入到GET请求里,最终生成一个参数值,从而简化了请求
     $params[$this->sign_key] = $this->_getSign($this->appid, $this->appsecret, time());
     switch (strtoupper($http_method)) {
         case 'GET':
             $result = $curl->get($url, $params, $this->debug);
             break;
         case 'POST':
             $result = $curl->post($url, $data, $params, $this->debug);
             break;
         default:
             throw new \Exception('不支持的HTTP请求方法');
     }
     if ($curl->getError()) {
         return \mysoft\helpers\String::jsonEncode(['success' => 0, 'data' => $curl->getError()]);
     }
     return $result;
 }
예제 #6
0
파일: QyHelper.php 프로젝트: gtyd/jira
 public static function getTicket($accessToken)
 {
     $curl = new Curl();
     return json_decode($curl->get(self::DDHTTP . '/get_jsapi_ticket?' . http_build_query(['access_token' => $accessToken, 'type' => 'jsapi'])), true);
 }
예제 #7
0
파일: ErpApiClient.php 프로젝트: gtyd/jira
 private function getAccessToken()
 {
     $curl = new Curl();
     $url = $this->_buildUrl('api/sys/GetAccessToken.ashx', $this->getApiPlartformSite());
     $param = ['timestamp' => date('Y-m-d\\TH:i:s'), 'appid' => $this->_appid];
     $token = $curl->get($url, $param);
     //发现http请求错误,抛出异常
     if ($curl->getError()) {
         throw new ErpApiTokenException($curl->getError());
     }
     $token = json_decode($token, true);
     if (!isset($token['errmsg']) && !isset($token['access_token'])) {
         throw new ErpApiTokenException('令牌服务器异常');
     }
     return $token;
 }