private function getSinaUserInfo(LJL_Request $input, LJL_Response $output) { $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $tokenInfo = LJL_Api::run('Open.Sina.getLoginTokens', array('code' => $input->get('code'), 'redirect_uri' => $redirect_uri)); $userInfo = LJL_Api::run('Open.Sina.getUserInfo', array('apiuid' => $tokenInfo['uid'], 'accessToken' => $tokenInfo['access_token'])); // var_dump($tokenInfo,$userInfo);die; $userMapInfo = array('api_uid' => $tokenInfo['uid'], 'api_name' => $userInfo['screen_name'], 'api_headimg' => $userInfo['profile_image_url'], 'api_profileurl' => $userInfo['profile_url'], 'api_token' => $tokenInfo['access_token'], 'api_type' => 'sina', 'expires_tm' => $tokenInfo['expires_in'], 'tm' => SYSTEM_TIME); $this->doRegister($input, $output, $userMapInfo); }
public function doMaketoken(LJL_Request $input) { $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . self::$WX_AKEY . '&secret=' . self::$WX_SKEY . ''; $tokenInfo = LJL_Api::run('Base.Http.curlPage', array('url' => $url, 'timeout' => 3)); $tokenPath = PRODUCTION_ROOT . '/Auto/Weixin/Page/token.php'; $token = (array) json_decode($tokenInfo); $token = $token['access_token']; file_put_contents($tokenPath, $token); exit; }
public function doSinalogin(LJL_Request $input, LJL_Response $output) { // $userInfo = LJL_Api::run('Open.Sina.getWeiboByUrl' , array( // //'apiuid' => '2004858905', // //'appuid' => '20', // //'name' => '崔洪波同学', // 'url' => 'http://cui.zhbor.com/article/13.html#0-tsina-1-38138-397232819ff9a47a7b7e80a40613cfe1', // )); // var_dump($userInfo);die; $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($input->get('code')) { $tokenInfo = LJL_Api::run('Open.Sina.getLoginTokens', array('code' => $input->get('code'), 'redirect_uri' => $redirect_uri)); $userInfo = LJL_Api::run('Open.Sina.getUserInfo', array('uid' => $tokenInfo['uid'], 'accessToken' => $tokenInfo['access_token'])); var_dump($tokenInfo); var_dump($userInfo); die; } $loginurl = LJL_Api::run('Open.Sina.getAuthorizeURL', array('redirect_uri' => $redirect_uri)); echo '<a href="' . $loginurl . '">微博登陆</a>'; die; }
<?php $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $loginurl = LJL_Api::run('Open.Sina.getAuthorizeURL', array('redirect_uri' => $redirect_uri)); ?> <div id="mask" class="mask"></div> <div id="model" class="model"> <span>账户信息</span> <a id="click-close" href='javascript:;' onclick='hideAll()'>×</a> <?php if ($pageType == 'login') { ?> <form id="user-login-form" action='' method='post'> 用户名:<input type='text' name='username' autofocus required placeholder="用户名/邮箱"><br/> 密 码:<input type='password' name='password' required><br/> <input id="user-login" type='submit' name='submit-btn' value="登录"> <a href="javascript:;" onclick="showAll('#model', 'showregister')">快速注册</a> <a href="<?php echo $loginurl; ?> " style="border-bottom: #666666 dashed 1px;font-weight: 600;font-size: 20px;">微博登录</a> </form> <?php } elseif ($pageType == 'register') { ?> <form id="user-register-form" action='' method='post'> 用户名:<input type='text' name='username' autofocus required placeholder="必填项"><br/> 邮 箱:<input type='email' name='email' required placeholder='必填项'><br/> 密 码:<input type='password' name='password1' placeholder='密码可为空'><br/> 密 码:<input type='password' name='password2' placeholder='密码可为空'><br/> <input id="user-register" type='submit' name='submit-btn' value="快速注册"> <a href="javascript:;" onclick="showAll('#model', 'showlogin')">登陆</a> <a href="<?php echo $loginurl; ?>
public function DoUploadImg(LJL_Request $input, LJL_Response $output) { $upfile = $input->files('uppic'); //客户端传过来的文件 $pos = strpos($upfile['name'], '.') + 1; $ext = substr($upfile['name'], $pos); //获取后缀名 $typelist = array("gif", "jpg", "png"); //限制图片类型 $imgInfo = LJL_Api::run("Image.DFS.imgStorage", array('rootdir' => UPLOAD_IMG_PATH . 'blog_' . APP_BLOG_NAME . '/')); $path = $imgInfo[2]; //上传到该文件夹 $webPath = Helper_Blog::getImgWebPath($imgInfo[2]); if (!is_dir($path)) { LJL_File::mkdir($path); } //获取图片名 $picName = $imgInfo[0]; $result = $this->uploadFile($upfile, $path, $picName, $webPath, $typelist); //图片上传函数 if ($result['status']) { //图片表中插入数据 $imgid = Helper_Blog::insertPic(array('picName' => $picName, 'picExt' => $ext, 'time' => $imgInfo[1])); echo '<script language="javascript">window.parent.addPic("' . $result['info'] . '","' . $imgid . '");</script>'; } else { echo '<script language="javascript">window.parent.addPic("error","0");</script>'; } }
/** * 获得手机号信息 */ public static function getMobileArea($paramArr) { $options = array('mobile' => ''); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); if (!$mobile || !preg_match('/^1[3458][0-9]{9}$/', $mobile)) { return false; } $outArr = array(); #首先尝试从db中查询 /** add by cui*/ $db = API_Db_Ip::instance(); $sql = "select * from mobile_data where mno = '{$mobile}' limit 1"; $re = $db->getRow($sql); if ($re) { $outArr = array('卡号归属地' => $re["area"], '卡类型' => $re["card"], '区号' => $re["areano"], '邮编' => $re["zip"]); return $outArr; } $outData = array(); #尝试接口1 $url = "http://www.ip138.com:8080/search.asp?action=mobile&mobile={$mobile}"; $dom = LJL_Api::run("Service.FetchHtml.getHtmlOrDom", array('url' => $url, 'charset' => 'gbk', 'timeout' => 3, 'getDom' => 1)); if ($dom) { $trs = $dom->find(".tdc"); if ($trs) { foreach ($trs as $tr) { $tds = $tr->find("td"); if (!isset($tds[0])) { continue; } $name = $tds[0]->innertext; $value = $tds[1]->innertext; $name = str_replace(array(" ", " "), "", strip_tags($name)); $name = iconv('gbk', 'utf-8', $name); $value = iconv('gbk', 'utf-8', $value); if (!in_array($name, array('卡类型', '区号', '邮编', '卡号归属地'))) { continue; } $value = str_replace(" ", "", strip_tags($value)); if ($name == '邮编') { $value = (int) $value; } if ($name == '卡号归属地') { $value = str_replace(" ", "|", $value); } if ($name && $value) { $outData[$name] = $value; } } } } if (!$outData) { #尝试接口2 $url = 'http://www.youdao.com/smartresult-xml/search.s?type=mobile&q=' . $mobile; $data = API_Http::curlPage(array('url' => $url, 'timeout' => 1)); if (preg_match("#<location>(.+)</location>#Ui", $data, $m)) { $outData['卡号归属地'] = trim(trim($m[1]), '|'); } } #将取得的数据记录到数据库,方便下次直接使用 /*bycui*/ if ($outData) { $sql = "insert into mobile_data(mno,area,card,areano,zip,tm)\r\n values('{$mobile}','" . $outData['卡号归属地'] . "','" . $outData['卡类型'] . "','" . $outData['区号'] . "','" . $outData['邮编'] . "','" . SYSTEM_TIME . "') "; $db->query($sql); } return $outData; }
private function getImgNameDir() { $imgInfo = LJL_Api::run("Image.DFS.imgStorage", array('rootdir' => $this->uploadRootdir . $this->website . '/')); $picName = $imgInfo[0]; // 0/1时间/2 $path = $imgInfo[2]; //上传到该文件夹 $webPath = $this->getImgWebPath($imgInfo[2]); if (!is_dir($path)) { LJL_File::mkdir($path); } return array($picName, $path, $webPath, $imgInfo[1]); }
/** * 输入错误关键字后给出提示信息 */ private function _notice($msg = '') { $answer = '1: PHP文章 ' . PHP_EOL; $answer .= '2: Linux文章' . PHP_EOL; $answer .= '3: MySQL文章' . PHP_EOL; $answer .= '4: JS相关文章' . PHP_EOL; $answer .= '5: 架构相关文章' . PHP_EOL; $answer .= '6: 随笔.生活' . PHP_EOL; $answer .= '7: 值得收藏' . PHP_EOL; $answer .= '----------------------------' . PHP_EOL; $answer .= '学习会儿吧' . PHP_EOL; $answer .= '回复数字找文章,例如:' . PHP_EOL; $answer .= '12代表第1类文章的第2页' . PHP_EOL; if ($msg) { $answer = $msg; } echo LJL_Api::run('Open.Weixin.answerText', array('content' => $answer)); die; }
/** * 根据图片信息,返回图片网络路径 */ public static function getPicWebPath($paramArr) { $options = array('imgName' => '', 'imgExt' => '', 'time' => '', 'rootdir' => '', 'size' => ''); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); $imgPath = LJL_Api::run("Image.DFS.getImgDir", array('imgName' => $imgName, 'time' => $time, 'rootdir' => $rootdir)); $webPath = self::getImgWebPath($imgPath); return $webPath . '/' . $size . $imgName . '.' . $imgExt; }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); //phpinfo();die; //输出二维码 require '/APILJL/Api.php'; #域名限制 $size_limit = array(100, 50, 70); #获取参数 $url = "www.baidu.com"; /*$url = isset($_GET ['url'])? trim ( $_GET ['url'] ) :false; if(!$url){ echo ' param error '; exit(); }*/ $size = intval($_GET['size']); $size = $size ? $size : 100; if (!in_array($size, $size_limit)) { echo ' param error '; exit; } $qrImg = LJL_Api::run("Image.QrCode.getQrCode", array('string' => $url, 'size' => $size, 'margin' => false, 'color' => '#AEC7E1', 'logoFile' => '/www/LJL/Html/Blogstaticfile/images/404.png', 'logoWidth' => 0)); Header("Content-type: image/png"); ImagePng($qrImg); ImageDestroy($qrImg); exit;
/** * 设置各种码的header信息 * @param int $code */ public static function sendHeaderCode($code) { LJL_Api::run("Base.Page.setExpires", array('second' => 0)); #清除过期时间 header('Content-type:text/html; Charset=utf-8'); header(self::getStatusByCode($code)); #设置404 header信息 }
/** * 执行API的方法 */ public static function run($method, $param = false) { if (!$method) { return false; } $method = str_replace('.', '_', $method); $class = 'API_Item_' . substr($method, 0, strrpos($method, '_')); $func = substr($method, strrpos($method, '_') + 1); self::$_nowMethod = $method; //通过私有云调用 $data = call_user_func_array(array($class, $func), array($param)); if (LJL_API_UTF8 && $data) { $data = self::toUTF8($data); return $data; } return $data; }