示例#1
0
 public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http')
 {
     $time = Pw::getTime();
     list($c, $a) = explode('/', $script);
     $query = array('m' => 'api', 'c' => $c, 'a' => $a, 'windidkey' => WindidUtility::appKey(WINDID_CLIENT_ID, $time, WINDID_CLIENT_KEY), 'clientid' => WINDID_CLIENT_ID, 'time' => $time);
     $url = WINDID_SERVER_URL . '/index.php?' . http_build_query($query) . '&' . http_build_query($getData);
     $result = WindidUtility::buildRequest($url, $postData);
     if ($result === false) {
         return WindidError::SERVER_ERROR;
     }
     return Pw::jsonDecode($result);
 }
示例#2
0
 public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http')
 {
     echo "here";
     $client = Windid::client();
     $time = time() + $client->timecv * 60;
     list($c, $a) = explode('/', $script);
     $query = array('m' => 'api', 'c' => $c, 'a' => $a, 'windidkey' => WindidUtility::appKey($client->clientId, $time, $client->clientKey), 'clientid' => $client->clientId, 'time' => $time);
     $url = $client->serverUrl . '/windid/index.php?' . http_build_query($query) . '&' . http_build_query($getData);
     $result = WindidUtility::buildRequest($url, $postData);
     if ($result === false) {
         return WindidError::SERVER_ERROR;
     }
     return WindJson::decode($result, true, $client->clientCharser);
 }
示例#3
0
 public function clientTestAction()
 {
     $clientid = $this->getInput('clientid');
     $client = $this->_getAppDs()->getApp($clientid);
     if (!$client) {
         $this->showError('WINDID:fail');
     }
     $time = Pw::getTime();
     $array = array('windidkey' => WindidUtility::appKey($client['id'], $time, $client['secretkey']), 'operation' => 999, 'uid' => 1, 'clientid' => $client['id'], 'time' => $time);
     $url = WindidUtility::buildClientUrl($client['siteurl'], $client['apifile']) . http_build_query($array);
     $result = WindidUtility::buildRequest($url);
     if ($result === 'seccess') {
         $this->showMessage('WINDID:success');
     }
     $this->showError('WINDID:fail');
 }
示例#4
0
 public function clientTestAction()
 {
     $clientid = $this->getInput('clientid');
     $client = $this->_getAppDs()->getApp($clientid);
     if (!$client) {
         $this->showError('WINDID:fail');
     }
     $time = Pw::getTime();
     $params['params'] = serialize(array('test' => $time));
     $windidkey = WindidUtility::appKey($client['id'], $time, $client['secretkey']);
     $url = WindidUtility::buildClientUrl($client['siteurl'], $client['apifile']) . 'operation=999&windidkey=' . $windidkey . '&clentid=' . $client['id'] . '&time=' . $time;
     $result = WindidUtility::buildRequest($url, $params);
     if ($result === 'seccess') {
         $this->showMessage('ADMIN:success');
     }
     $this->showError('ADMIN:fail');
 }
示例#5
0
 public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http')
 {
     $time = Pw::getTime();
     list($c, $a) = explode('/', $script);
     $getData['m'] = 'api';
     $getData['c'] = $c;
     $getData['a'] = $a;
     $getData['clientid'] = WINDID_CLIENT_ID;
     $getData['time'] = $time;
     $getData['windidkey'] = WindidUtility::appKey(WINDID_CLIENT_ID, $time, WINDID_CLIENT_KEY, $getData, $postData);
     $url = WINDID_SERVER_URL . '/index.php?' . http_build_query($getData);
     if (!(strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0)) {
         return false;
     }
     //$result = file_get_contents($url);
     $result = WindidUtility::buildRequest($url, $postData);
     if ($result === false) {
         return WindidError::SERVER_ERROR;
     }
     return Pw::jsonDecode($result);
 }
示例#6
0
 public function logSend($logid)
 {
     $time = Windid::getTime();
     $logDs = $this->_getNotifyLogDs();
     $log = $logDs->getLog($logid);
     if (!$log) {
         return false;
     }
     $app = $this->_getAppDs()->getApp($log['appid']);
     $notify = $this->_getNotifyDs()->getNotify($log['nid']);
     $array = array('windidkey' => WindidUtility::appKey($log['appid'], $time, $app['secretkey']), 'operation' => $notify['operation'], 'uid' => (int) $notify['param'], 'clientid' => $log['appid'], 'time' => $time);
     $url = WindidUtility::buildClientUrl($app['siteurl'], $app['apifile']) . http_build_query($array);
     $result = WindidUtility::buildRequest($url);
     $dm = new WindidNotifyLogDm($logid);
     if ($result == 'seccess') {
         $dm->setComplete(1)->setIncreaseSendNum(1);
         $logDs->updateLog($dm);
         return true;
     } else {
         $dm->setComplete(0)->setIncreaseSendNum(1)->setReason('fail');
         $logDs->updateLog($dm);
         return false;
     }
 }
示例#7
0
 /**
  * 保存phpwind.aliyun.com帮站长申请关于悟空的im应用密匙 
  * 
  * @param mixed $key 
  * @static
  * @access public
  * @return void
  */
 public static function saveAppekySetting($key)
 {
     $config = Wekit::C()->getConfigByName('site', 'info.url');
     $_uri = self::PW_CREATER_URI . '/api/getlaiwanginfo?siteurl=' . urlencode($config['value']);
     $unsecurityKey = WindidUtility::buildRequest($_uri, array(), true, self::WK_TIMEOUT, 'get');
     $unsecurityKey = json_decode($unsecurityKey, true);
     if ($unsecurityKey && $unsecurityKey['status'] == 200) {
         $_unsecurityKey = Pw::decrypt($unsecurityKey['data']['info'], $key);
         $appSettingData = unserialize($_unsecurityKey);
         // 解密错了或者其他情况不保存空的数据到数据库
         if (!$appSettingData) {
             return array();
         }
         // 保存laiwang appkey等
         $config = new PwConfigSet('wukong');
         $config->set('appToken', $appSettingData['appToken'])->set('domain', $appSettingData['domain'])->set('org', $appSettingData['org'])->set('android.appKey', $appSettingData['Android']['appKey'])->set('android.appSecret', $appSettingData['Android']['appSecret'])->set('ios.appKey', $appSettingData['iOS']['appKey'])->set('ios.appSecret', $appSettingData['iOS']['appSecret'])->flush();
         return $appSettingData;
     }
     return array();
 }
示例#8
0
 public function shutdownSend()
 {
     $url = Windid::client()->serverUrl . '/windid/index.php?m=queue';
     WindidUtility::buildRequest($url, array(), false, 10);
     return true;
 }
 public function shutdownSend($nid)
 {
     $url = Wekit::app('windid')->url->base . '/index.php?m=queue';
     WindidUtility::buildRequest($url, array('nid' => $nid), false, 10);
     return true;
 }
示例#10
0
 protected function downloadThirdPlatformAvatar($uid, $avatar_url)
 {
     Wind::import('WSRV:base.WindidUtility');
     $image_content = WindidUtility::buildRequest($avatar_url, array(), true, 2, 'get');
     if ($image_content) {
         $temp_file = tempnam(PUBLIC_PATH . "data/tmp/", 'tmp_');
         $handle = fopen($temp_file, "w");
         if ($handle) {
             $res = fwrite($handle, $image_content);
             fclose($handle);
             Wind::import('WSRV:upload.action.WindidAvatarUpload');
             Wind::import('LIB:upload.PwUpload');
             $bhv = new WindidAvatarUpload($uid);
             $upload = new PwUpload($bhv);
             $value = array('name' => 'avatar.jpg', 'size' => 1024 * 1024 * 1, 'tmp_name' => $temp_file);
             $file = new PwUploadFile('_0', $value);
             $file->filename = $upload->filterFileName($bhv->getSaveName($file));
             $file->savedir = $bhv->getSaveDir($file);
             $file->store = Wind::getComponent($bhv->isLocal ? 'localStorage' : 'storage');
             $file->source = str_replace('attachment', 'windid/attachment', $file->store->getAbsolutePath($file->filename, $file->savedir));
             if (PwUpload::moveUploadedFile($value['tmp_name'], $file->source)) {
                 $image = new PwImage($file->source);
                 if ($bhv->allowThumb()) {
                     $thumbInfo = $bhv->getThumbInfo($file->filename, $file->savedir);
                     foreach ($thumbInfo as $key => $value) {
                         $thumburl = $file->store->getAbsolutePath($value[0], $value[1]);
                         $thumburl = str_replace('attachment', 'windid/attachment', $thumburl);
                         $result = $image->makeThumb($thumburl, $value[2], $value[3], $quality, $value[4], $value[5]);
                         if ($result === true && $image->filename != $thumburl) {
                             $ts = $image->getThumb();
                         }
                     }
                 }
             }
             @unlink($temp_file);
         }
     }
 }
 /**
  * 淘宝; 暂时不支持 
  * 
  * @access public
  * @return void
  */
 public function taobaoAuthInfo()
 {
     //
     $this->_appid = $this->_third_platform_conf[$this->third_platform_name . '.appId'];
     $this->_appkey = $this->_third_platform_conf[$this->third_platform_name . '.appKey'];
     //step 1
     $_access_token = $this->_session->get($this->third_platform_name . '_access_token');
     if (empty($_access_token)) {
         $_uri = sprintf($this->_third_platform_uri_conf[$this->third_platform_name]['access_token_uri'], $this->_appid, $this->_appkey, $this->auth_code, $this->native_name);
         $_uri_data = parse_url($_uri);
         $_uri = sprintf('%s://%s%s', $_uri_data['scheme'], $_uri_data['host'], $_uri_data['path']);
         parse_str($_uri_data['query'], $postdata);
         $_access_token_result = WindidUtility::buildRequest($_uri, $postdata, true, 2);
         $_args = json_decode($_access_token_result, true);
         if (isset($_args['access_token'])) {
             $_access_token = $_args['access_token'];
             $this->_session->set($this->third_platform_name . '_access_token', $_access_token);
         }
     }
     exit;
     //step 2
     if ($_access_token) {
         $_uri = sprintf($this->_third_platform_uri_conf[$this->third_platform_name]['userinfo_uri'], $_access_token['access_token'], $_access_token['uid'], $this->_appkey);
         $_userinfo_result = WindidUtility::buildRequest($_uri, array(), true, 2, 'get');
         $_userinfo_result = json_decode($_userinfo_result, true);
         //
         if (isset($_userinfo_result['name'])) {
             $info = array('uid' => '', 'username' => $_userinfo_result['name'], 'gender' => $_userinfo_result['gender'] == 'm' ? 0 : 1, 'avatar' => $_userinfo_result['avatar_large']);
         }
         unset($_userinfo_result);
     }
     if (empty($info) || !isset($info)) {
         $this->_session->delete($this->third_platform_name . '_access_token');
     }
     return $info;
 }
 protected function _request($url, $params, $method = 'get')
 {
     $result = WindidUtility::buildRequest($url, $params, true, self::HTTP_TIMEOUT, $method);
     return !empty($result) ? $result : false;
 }