【小程序开发之坑】
由于移动站加入了微信公众号,小程序和微信公众号开发公用的域名,导致小程序请求数据的时候总是跳转到微信的请在微信打开该页面,无法获取数据,最后采用小程序提交的时候带标识参数,在程序里面判断是来自于小程序,不按微信公众号的方式跳转
E:\web\secake 正式\mobile\app\Modules\Base\Controllers\FrontendController.php
public function __construct()
{
parent::__construct();
/*小程序cookie处理start*/
require_once "/vendor/Guzzle/Parser/Cookie/CookieParserInterface.php";
require_once "/vendor/Guzzle/Parser/Cookie/CookieParser.php";
//[cookie] => yunsuo_session_verify=a4270bdf292fd9a98cb1485ede261199;
expires=Fri, 13-Apr-18 19:18:24 GMT;
path=/;
HttpOnly,dsc_real_ip=171.115.146.202;
expires=Tue, 10-Apr-2018 21:18:24 GMT;
Max-Age=36000;
path=/,ECS_ID=216941f346f1cebde33055ef27ebcc168ebd6313;
path=/,ECS[visit_times]=1;
expires=Wed, 10-Apr-2019 03:18:24 GMT;
Max-Age=31507200;
path=/,province=13;
expires=Thu, 10-May-2018 03:18:24 GMT;
Max-Age=2563200;
path=/,city=196;
expires=Thu, 10-May-2018 03:18:24 GMT;
Max-Age=2563200;
path=/,district=1639;
expires=Thu, 10-May-2018 03:18:24 GMT;
Max-Age=2563200;
path=/,street=0;
expires=Thu, 10-May-2018 03:18:24 GMT;
Max-Age=2563200;
path=/,street_area=0;
expires=Thu, 10-May-2018 03:18:24 GMT;
Max-Age=2563200;
path=/,session_id_ip=171.115.146.202_216941f346f1cebde33055ef27ebcc16;
expires=Wed, 10-Apr-2019 03:18:25 GMT;
Max-Age=31507200;
path=/,yunsuo_session_verify=a4270bdf292fd9a98cb1485ede261199;
expires=Fri, 13-Apr-18 19:18:24 GMT;
path=/;
HttpOnly
$headers = $this->get_all_headers();
$cookie = $headers['cookie'];
$cookienew = $this->parse_cookie_string($cookie);
foreach ($cookienew as $cookiename => $cookievalue){
$c = explode('=',$cookievalue);
if($c[0] == 'session_id_ip'){
cookie('mini_session_id_ip',$c[1],365*24*60*60);
//cookie('session_id_ip',$c[1],365*24*60*60);
}
}
/*小程序cookie处理end*/
if(isset($_REQUEST['from'])){
cookie('from','miniprogram');
}$this->start();
$this->ecjia_login();
}
function is_wechat_browser()
{
if(cookie('from')){
return false;
}
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($user_agent, 'micromessenger') === false) {
return false;
}
else {
return true;
}
}
推荐阅读
- 对GO切片的理解
- 小程序商城网站开发秒杀模块篇
- 盲盒购物网站系统开发建设 第三篇
- Netty核心概念之ChannelHandler&Pipeline&ChannelHandlerContext
- 简单的线程池实现多线程对大文件的读取
- SSH 端口转发与 SOCKS 代理
- Ubuntu16.04/Scala2.11.8安装教程
- 学习PHP中的高精度计时器HRTime扩展
- 使用OpenResty+Lua实现灰度测试(金丝雀)
- 使用源码编译安装PHP扩展