小程序开发之坑


【小程序开发之坑】由于移动站加入了微信公众号,小程序和微信公众号开发公用的域名,导致小程序请求数据的时候总是跳转到微信的请在微信打开该页面,无法获取数据,最后采用小程序提交的时候带标识参数,在程序里面判断是来自于小程序,不按微信公众号的方式跳转
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; } }



    推荐阅读