微信小程序生成小程序二维码 php 直接可以用
微信小程序开发交流qq群 581478349
承接微信小程序开发。扫码加微信。
小程序需要先上线才能生成二维码
HTTP请求的效果图:
小程序展示的效果图:
小程序展示二维码源码:
请求二维码图片base64路径,点击预览图片
onLoad: function (options) {var that=this;util.request('http://localhost/erweima.php', 'get', { openid: wx.getStorageSync('openid'),toopenid:'123' }, '', function (res) {that.setData({scene: res.data})})}previewImage: function (e) {wx.previewImage({urls: this.data.scene.split(',')// 需要预览的图片http链接 })},
<image class='img' bindtap="previewImage" src='{{scene}}'></image>
PHP源码:
<?phpheader("Content-Type:text/html;charset=utf8"); header("Access-Control-Allow-Origin: *"); //解决跨域header('Access-Control-Allow-Methods:GET');// 响应类型 header('Access-Control-Allow-Headers:*'); // 响应头设置 $link=mysql_connect("localhost","root","root"); mysql_select_db("business_card", $link); //选择数据库mysql_query("SET NAMES utf8");//解决中文乱码问题XgetWxcode();function getWxAccessToken(){$appid='appid';//填你的appid$appsecret='appsecret';//填你的appsecret$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret;$access_token = makeRequest($url);$access_token = json_decode($access_token['result'],true);return $access_token;
}
/*** 发起http请求* @param string $url 访问路径* @param array $params 参数,该数组多于1个,表示为POST* @param int $expire 请求超时时间* @param array $extend 请求伪造包头参数* @param string $hostIp HOST的地址* @return array 返回的为一个请求状态,一个内容*/
function makeRequest($url, $params = array(), $expire = 0, $extend = array(), $hostIp = '')
{if (empty($url)) {return array('code' => '100');}$_curl = curl_init();$_header = array('Accept-Language: zh-CN','Connection: Keep-Alive','Cache-Control: no-cache');// 方便直接访问要设置host的地址if (!empty($hostIp)) {$urlInfo = parse_url($url);if (empty($urlInfo['host'])) {$urlInfo['host'] = substr(DOMAIN, 7, -1);$url = "http://{$hostIp}{$url}";} else {$url = str_replace($urlInfo['host'], $hostIp, $url);}$_header[] = "Host: {$urlInfo['host']}";}// 只要第二个参数传了值之后,就是POST的if (!empty($params)) {curl_setopt($_curl, CURLOPT_POSTFIELDS, http_build_query($params));curl_setopt($_curl, CURLOPT_POST, true);}if (substr($url, 0, 8) == 'https://') {curl_setopt($_curl, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($_curl, CURLOPT_SSL_VERIFYHOST, FALSE);}curl_setopt($_curl, CURLOPT_URL, $url);curl_setopt($_curl, CURLOPT_RETURNTRANSFER, true);curl_setopt($_curl, CURLOPT_USERAGENT, 'API PHP CURL');curl_setopt($_curl, CURLOPT_HTTPHEADER, $_header);if ($expire > 0) {curl_setopt($_curl, CURLOPT_TIMEOUT, $expire); // 处理超时时间curl_setopt($_curl, CURLOPT_CONNECTTIMEOUT, $expire); // 建立连接超时时间}// 额外的配置if (!empty($extend)) {curl_setopt_array($_curl, $extend);}$result['result'] = curl_exec($_curl);$result['code'] = curl_getinfo($_curl, CURLINFO_HTTP_CODE);$result['info'] = curl_getinfo($_curl);if ($result['result'] === false) {$result['result'] = curl_error($_curl);$result['code'] = -curl_errno($_curl);}curl_close($_curl);return $result;
}
function getWxcode(){$ACCESS_TOKEN=getWxAccessToken();$url="https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$ACCESS_TOKEN['access_token'];$post_data=array('page'=>'pages/index/index','scene'=>'34,S853EE4QRP'//34%2CS853EE4QRP);$post_data=json_encode($post_data);$data=send_post($url,$post_data);$result=data_uri($data,'image/png');echo $result;return '<image src='.$result.'></image>';}/*** 消息推送http* @param $url* @param $post_data* @return bool|string*/
function send_post( $url, $post_data ) {$options = array('http' => array('method' => 'POST','header' => 'Content-type:application/json',//header 需要设置为 JSON'content' => $post_data,'timeout' => 60//超时时间));$context = stream_context_create( $options );$result = file_get_contents( $url, false, $context );return $result;}
//二进制转图片image/png
function data_uri($contents, $mime)
{$base64 = base64_encode($contents);return ('data:' . $mime . ';base64,' . $base64);
}
?>
把二维码保存到用户的手机博客源码链接 点击跳转
相关文章:

vue和react相同点_我在React和Vue中创建了相同的应用程序。 这是区别。
vue和react相同点by Sunil Sandhu由Sunil Sandhu 我在React和Vue中创建了相同的应用程序。 这是区别。 (I created the same app in React and Vue. Here are the differences.) Having used Vue at my current workplace, I had a fairly solid understanding of how it all …

Filter(过滤器)
一、Filter过滤器(重要) Javaweb中的过滤器可以拦截所有访问web资源的请求或响应操作。 1、Filter快速入门 1.1、步骤: 1. 创建一个类实现Filter接口 2. 重写接口中方法 doFilter方法是真正过滤的。 3. 在web.xml文件中配置 …

css3实现3D立体翻转效果
1、在IE下无法显示翻转效果,火狐和谷歌可以 1 /*样式css*/2 3 .nav-menu li {4 display: inline;5 }6 .nav-menu li a {7 color: #fff;8 display: block;9 text-decoration: none;10 overflow: visible;11 line-height: 40px;12 font-…

Ant Design 入门-参照官方文档使用组件
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 先来一个按钮组件使用的对比,官方文档的(不能直接用)和实际能用的。 官网demo: import { Table, Divider, Tag } from antd;const columns = [{title: Name,dataIndex: name,key: name,render: text =…

如何用JavaScript的回调函数做出承诺
by Adham El Banhawy由Adham El Banhawy 如何用JavaScript的回调函数做出承诺 (How to make a Promise out of a Callback function in JavaScript) Back-end developers run into challenges all the time while building applications or testing code. As a developer who …

VMware里的linux系统里的命令行里会有bee的声音,要如何关掉
VMware里的linux系统里的命令行里会有bee的声音,要如何关掉 取消bell报警声的方法:登陆linux系统vi /etc/inputrc找到set bell-style none 将前面的#去掉,之后重启系统即可解决声音问题若不见效可以通过下面的方式解决下bell-styl…

React-Todos
最近学完React的最基本概念,闲下来的时候就自己写了一个Todo-List的小应用。这里做个简略的说明,给想好好学React的新手看。 React-Todo 学习前提 这里我用了webpackb做了babel和JSX预处理和模块打包。所以对React和一些ES2015(ES6࿰…

Ant Design 入门-引用自己命名的组件
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 自己创建的组件:代码 import { Table, Divider, Tag } from antd; import React, { Component } from react; export default class My_Table extends Component {render() {const columns = [{title: …

迷宫出路代码_如何在软件开发的迷宫中找到自己的出路
迷宫出路代码by Tim Kleier蒂姆克莱尔(Tim Kleier) 如何在软件开发的迷宫中找到自己的出路 (How to find your way through the corn maze of software development) The corn maze is one of my favorite challenges to tackle. It’s an unnerving experience, especially w…

打包 React 项目并在服务器运行。
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.找到项目根目录的package.json文件:如图: 2.打开cmd执行:npm run build 3.生成DIST文件夹。 4.把DIST文件放到服务器phpStudty根目录,访问index.html。…

一些有用的Python问题
1. 修改IDLE工作路径,在命令交互模式下输入如下指令: >>> import os >>> os.getcwd() #查看当前的工作路径 >>> os.chdir(E:\\Python\\Demo) #修改当前的工作路径 2.Python中 ImportError: cannot import name NUMPY_MKL 的…

Python核心编程笔记---- print
在仅用变量名时,输出的字符串是用单引号括起来的。这个是为了让非字符串对象也可能以字符的形式显示在屏幕上。 而print 函数打印出来的是变量的值。 print 调用的是str()方法。而仅用变量名时调用的是repr()方法。 证明:------------------------------…

latex 插图解释_大O符号-只需插图和视频即可解释
latex 插图解释Big O notation is used to communicate how fast an algorithm is. This can be important when evaluating other people’s algorithms, and when evaluating your own! In this article, I’ll explain what Big O notation is and give you a list of the m…

[YTU]_2002(C语言实验——单词统计)
Description 从键盘输入一行字符,统计其中单词的个数,各单词以空格分隔,且空格数可以是多个。Input 输入只有一行句子。仅有空格和英文字母构成。 Output 单词的个数。 Sample Input stable marriage problem Consists of Matching memb…

资本中国人物-金融
一、二、三、店、五、土地、七、八、玖、拾起、白、千、一万、一亿、元(圆)、角、支、零、整个。这是上图中我们经常要填写。问:什么是它用数词?想必很多人都不是很清楚! 请看下面的两个相关的表数词: 1、数字化和大、小写数字对照…

Ant Design Pro 网络请求流程
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 在 Ant Design Pro 中,一个完整的前端 UI 交互到服务端处理流程是这样的: UI 组件交互操作; 调用 model 的 effect; 调用统一管理的 service 请求函数&a…

在Google Cloud Platform上持续部署Node.js
by Gautam Arora由Gautam Arora 在Google Cloud Platform上持续部署Node.js (Continuous Deployment for Node.js on the Google Cloud Platform) Google Cloud Platform (GCP) provides a host of options for Node developers to easily deploy our apps. Want a managed ho…

hdu-1108 最小公倍数
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid1108 题目类型: 数论 题意概括: 求两个数的最小公倍数 解题思路: 模拟 题目: 最小公倍数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O…

sql-schema与catalog
schema: 指的是说当偶create database caiceclb时,caiceclb就是一个schema catalog: 指的是所有的database目录,就像上图显示的那样,将MySQL原来的(mysql,infomation_schema)及后来新建的的data…

这是如何更好地利用JavaScript数组的方法
by pacdiv由pacdiv 这是如何更好地利用JavaScript数组的方法 (Here’s how you can make better use of JavaScript arrays) Quick read, I promise. Over the last few months, I noticed that the exact same four mistakes kept coming back through the pull requests I c…

07、C语言——函数
函数 1、函数定义 函数返回值类型 函数名(形式参数列表) { 函数体; } 注意: 定义有参函数时,形参的定义可以采用传统方式或现代方式两种 1)传统方式: int …

This is probably not a problem with npm. There is likely additional logging output above
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 E:\weii_objct\invoice-manage-web-view>npm start > ant-design-pro@2.1.0 start E:\weii_objct\invoice-manage-web-view > cross-env APP_TYPE=site umi dev cross-env 不是内部或外部命令…

parcel react_如何使用Parcel捆绑React.js应用程序
parcel reactby Michael Ozoemena迈克尔奥索埃梅纳(Michael Ozoemena) 如何使用Parcel捆绑React.js应用程序 (How to use Parcel to bundle your React.js application) 什么是包裹? (What’s Parcel?) Parcel is a web application bundler which offers a blazi…

SparkSQL 与 Spark Core的关系
不多说,直接上干货! SparkSQL 与 Spark Core的关系 Spark SQL构建在Spark Core之上,专门用来处理结构化数据(不仅仅是SQL)。 Spark SQL在Spark Core的基础上针对结构化数据处理进行很多优化和改进, 简单来讲: Spark SQ…

linux操作系统-设置静态ip
在使用linux虚拟机的时候因为经常有关机的需求,然后重新开机后可能面临这上一次获取的ip被改变,在这里我分享一下在linux 下设置静态ip的经验 1.查看路由状态 [rootlocalhost ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Met…

判断数组里面的下标是否等于一个字符串
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 使用includes() 1、判断字符串里面是否包含一个字符串 示例: var a aaaaaaaavconsole.log(a.includes(v)); //truevar a aaaaaaaavconsole.log(a.includes(c)); //falsevar a aa…

如何获得更多的自由开发者客户
by Jad Joubran通过贾德乔布兰(Jad Joubran) 如何获得更多的自由开发者客户 (How to get more clients as a freelance developer) 我希望几年前知道的实用技巧 (Practical tips I wish I knew a few years ago) Whenever a conversation about freelancing kicks off with fe…

2017.6.4 入门组 NO.2——睡眠
其实这题就是将第二个时间-第一个时间,小于0的补全就A了代码如下: var x,y,k:string;l1,l2,x1,x2,x3,y1,y2,y3:longint; beginreadln(x);readln(y);l1:pos(:,x);l2:pos(:,y);k:copy(x,1,2); val(k,x1);k:copy(x,l11,2); val(k,y1);k:copy(y,1,2); val(k…

微信小程序获取用户收货地址 完整代码
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 获取用户收货地址需要用户点击授权,所以有两种情况,确认授权、取消授权。 情况一,用户第一次访问用户地址授权,并且点击确定授权。 情况二,用…

easyui的combobox下拉框初始化默认值以及保持该值一直显示的方法
easyui的combobox下拉框默认初始值是空,下面是实现从远程加载数据之后初始化默认值,以及让该值一直排在下拉框的最顶部的方式。 目前的需求是需要在初始化的时候添加"全部数据库"字段,并且在下拉的时候,"全部数据库"一直排在最顶部。 初始化效果…