2018年2月

微信H5支付,微信公众号以外浏览器唤起微信支付,页面,控制器,模型已经写好,换掉信息即可

public function notify(){
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
libxml_disable_entity_loader(true);
$arr= json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
if($arr['return_code']=='SUCCESS'){
$oid = $arr['out_trade_no'];
$da = Db::name('Order')->where('order_num',$oid)->find();
if($da['isfalse']==0){
Db::name('Order')->where('order_num',$oid)->update(['isfalse'=>1,'status'=>1]);
}
}
}

百度下载:传送门 资源密码:74ge

PHP模拟微信浏览器打开微信链接

微信浏览器的HTTP_USER_AGENT

在iPhone下,返回

Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2

在Android下,返回

Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255

不难发现微信浏览器为 MicroMessenger ,并且有版本号,也可以判断手机类型为iPhone还是Android

  1. get 方式 function get($url, $referer, $cookie) { $header = array(); $header[] = 'Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, /'; $header[] = 'Connection: Keep-Alive'; $header[] = 'Accept-Language: zh-cn'; $header[] = 'Cache-Control: no-cache'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2'); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $result = curl_exec($ch); curl_close($ch); return $result; }

    echo get('微信端网址','',''); 
  2. post方式

    function post($url, $data, $referer, $cookie) { 
    $header = array(); 
    $header[] = 'Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*'; 
    $header[] = 'Connection: Keep-Alive'; 
    $header[] = 'Accept-Language: zh-cn'; 
    $header[] = 'Cache-Control: no-cache'; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_HEADER, 1); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255'); 
    curl_setopt($ch, CURLOPT_REFERER, $referer); 
    curl_setopt($ch, CURLOPT_COOKIE, $cookie); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
    $result = curl_exec($ch); 
    curl_close($ch); 
    return $result; 
    }     
    
    echo post('微信端网址','','','');   
  3. 防盗链

    if(strpos($_SERVER["HTTP_USER_AGENT"],"MicroMessenger")){
    echo "Welcome to wechat word"; }
    else {
    echo "http/1.1 401 Unauthorized";}