《微信开发》"errcode": 40164, "errmsg": "invalid ip 220.115.189.50, not in whitelist"(FAQs)
接口调试返回"errcode": 40164, "errmsg": "invalid ip 220.115.189.50, not in whitelist"
解决办法:
【登录公众后台】——【设置】——【基本设置】——【白名单添加】
备注说明:
这里添加的是你本地的IP地址(公网),不会查询点击这里
接口调试返回"errcode": 40164, "errmsg": "invalid ip 220.115.189.50, not in whitelist"
解决办法:
【登录公众后台】——【设置】——【基本设置】——【白名单添加】
备注说明:
这里添加的是你本地的IP地址(公网),不会查询点击这里
很多不太懂正则的朋友,在遇到需要用正则校验数据时,往往是在网上去找很久,结果找来的还是不很符合要求。所以我最近把开发中常用的一些正则表达式整理了一下,在这里分享一下。给自己留个底,也给朋友们做个参考。
一、校验数字的表达式
1、数字:^[0-9]*$
2、n位的数字:^d{n}$
3、至少n位的数字:^d{n,}$
4、m-n位的数字:^d{m,n}$
5、零和非零开头的数字:^(0|1-9*)$
6、非零开头的最多带两位小数的数字:^(1-9*)+(.[0-9]{1,2})?$
7、带1-2位小数的正数或负数:^(-)?d+(.d{1,2})?$
8、正数、负数、和小数:^(-|+)?d+(.d+)?$
9、有两位小数的正实数:^[0-9]+(.[0-9]{2})?$
10、有1~3位小数的正实数:^[0-9]+(.[0-9]{1,3})?$
11、非零的正整数:^[1-9]d$ 或 ^([1-9][0-9]*){1,3}$ 或 ^+?1-9$
12、非零的负整数:^-[1-9][]0-9"*$ 或 ^-[1-9]\d*$
13、非负整数:^d+$ 或 ^[1-9]\d*|0$
14、非正整数:^-[1-9]d*|0$ 或 ^((-\d+)|(0+))$
15、非负浮点数:^d+(.d+)?$ 或 ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$
16、非正浮点数:^((-d+(.d+)?)|(0+(.0+)?))$ 或 ^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$
17、正浮点数:^[1-9]d.d|0.d[1-9]d$ 或 ^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$
18、负浮点数:^-([1-9]d.d|0.d[1-9]d)$ 或 ^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$
19、浮点数:^(-?d+)(.d+)?$ 或 ^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$
二、校验字符的表达式
1、汉字:^[u4e00-u9fa5]{0,}$
2、英文和数字:^[A-Za-z0-9]+$ 或 ^[A-Za-z0-9]{4,40}$
3、长度为3-20的所有字符:^.{3,20}$
3、由26个英文字母组成的字符串:^[A-Za-z]+$
5、由26个大写英文字母组成的字符串:^[A-Z]+$
6、由26个小写英文字母组成的字符串:^[a-z]+$
7、由数字和26个英文字母组成的字符串:^[A-Za-z0-9]+$
8、由数字、26个英文字母或者下划线组成的字符串:^w+$ 或 ^\w{3,20}$
9、中文、英文、数字包括下划线:^[u4E00-u9FA5A-Za-z0-9_]+$
10、中文、英文、数字但不包括下划线等符号:^[u4E00-u9FA5A-Za-z0-9]+$ 或 ^[\u4E00-\u9FA5A-Za-z0-9]{2,20}$
11、可以输入含有^%&',;=?$\"等字符:[^%&',;=?$x22]+
12、禁止输入含有~的字符:1+
三、特殊需求表达式
1、Email地址:^w+([-+.]w+)@w+([-.]w+).w+([-.]w+)*$
2、域名:a-zA-Z0-9{0,62}(/.a-zA-Z0-9{0,62})+/.?
3、 InternetURL:[a-zA-z]+://2 或 ^http://([w-]+.)+[w-]+(/[w-./?%&=])?$
4、手机号码:^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])d{8}$
5、电话号码("-X"、"X-XX"、"-X"、"-XX"、"X"和"XX):^((d{3,4}-)|d{3.4}-)?d{7,8}$
6、国内电话号码(0511-4405222、021-87888822):d{3}-d{8}|d{4}-d{7}
7、身份证号(15位、18位数字):^d{15}|d{18}$
8、短身份证号码(数字、字母x结尾):^([0-9]){7,18}(x|X)?$ 或 ^\d{8,18}|[0-9x]{8,18}|[0-9X]{8,18}?$
9、帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线):^a-zA-Z{4,15}$
10、密码(以字母开头,长度在6~18之间,只能包含字母、数字和下划线):^[a-zA-Z]w{5,17}$
11、强密码(必须包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间):^(?=.d)(?=.[a-z])(?=.*[A-Z]).{8,10}$
12、日期格式:^d{4}-d{1,2}-d{1,2}
13、一年的12个月(01~09和1~12):^(0?[1-9]|1[0-2])$
14 、一个月的31天(01~09和1~31):^((0?[1-9])|((1|2)[0-9])|30|31)$
15、钱的输入格式:
有四种钱的表示形式我们可以接受:"10000.00" 和 "10,000.00", 和没有 "分" 的 "10000" 和 "10,000":^1-9*$
这表示任意一个不以0开头的数字,但是,这也意味着一个字符"0"不通过,所以我们采用下面的形式:^(0|1-9*)$
一个0或者一个不以0开头的数字.我们还可以允许开头有一个负号:^(0|-?1-9*)$
这表示一个0或者一个可能为负的开头不为0的数字.让用户以0开头好了.把负号的也去掉,因为钱总不能是负的吧.下面我们要加的是说明可能的小数部分:^[0-9]+(.[0-9]+)?$
5.必须说明的是,小数点后面至少应该有1位数,所以"10."是不通过的,但是 "10" 和 "10.2" 是通过的:^[0-9]+(.[0-9]{2})?$
6.这样我们规定小数点后面必须有两位,如果你认为太苛刻了,可以这样:^[0-9]+(.[0-9]{1,2})?$
这样就允许用户只写一位小数.下面我们该考虑数字中的逗号了,我们可以这样:^[0-9]{1,3}(,[0-9]{3})*(.[0-9]{1,2})?$
1到3个数字,后面跟着任意个 逗号+3个数字,逗号成为可选,而不是必须:^([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(.[0-9]{1,2})?$
备注:这就是最终结果了,别忘了"+"可以用"*"替代如果你觉得空字符串也可
以接受的话(奇怪,为什么?)最后,别忘了在用函数时去掉去掉那个反斜杠,一般的错误都在这里
16、xml文件:^([a-zA-Z]+-?)+[a-zA-Z0-9]+\.x|X[l|L]$
17、中文字符的正则表达式:[u4e00-u9fa5]
18、双字节字符:3 (包括汉字在内,可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1))
19、空白行的正则表达式:ns*r (可以用来删除空白行)
20、HTML标记的正则表达式:<(S?)4>.?</1>|<.? /> (网上流传的版本太糟糕,上面这个也仅仅能部分,对于复杂的嵌套标记依旧**为力)
21、首尾空白字符的正则表达式:^s|s$或(^\s*)|(\s*$) (可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式)
22、 腾讯QQ号:1-9{4,} (腾讯QQ号从10000开始)
23、中国邮政编码:[1-9]d{5}(?!d) (中国邮政编码为6位数字)
24、IP地址:d+.d+.d+.d+ (提取IP地址时有用)
25、 IP地址:((??:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))
最近在做搭建直播流服务器时候发现【推流正常】,却无法【录制.flv】,下面是排查的方法:
1、检查nginx的当前状态
ps -aux|grep nginx
2、发现worker进程的用户居然是nobody
这nobody用户是没有写入权限的 ,所有nginx的运行用户不能用默认的nobody
3、在conf的首行
user root #用最高权限运行
4、修改后,重启nginx
5、测试成功
ps -aux|grep nginx
centos 7.2 安装Nginx和nginx-rtmp-module搭建直播流媒体服务器
本机安装目录
/usr/share/
1、在当前目录下载同版本的Nginx
cd /usr/share/
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
2、更新下依赖相关包
yum -y install pcre*
3、下载nginx-rtmp-module
cd /usr/share/
git clone https://github.com/arut/nginx-rtmp-module.git
mv nginx-rtmp-module nginx-rtmp-module-1.1.10
4、进入nginx-1.12.2目录
cd /usr/share/nginx-1.12.2
5、编译模块
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module-1.1.10 --with-
http_ssl_module
make #验证
make install
6、启动Nginx
cd /usr/local/nginx
./sbin/nginx
7、配置conf
参考资料
github:《nginx-rtmp-module》https://github.com/arut/nginx-rtmp-module
复制一份副本
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
编辑配置
vi /usr/local/nginx/conf/nginx.conf
rm -rf /usr/local/nginx/conf/.nginx.conf.swp
在events {}下面添加以下代码
参考《Nginx.conf》
nginx.rar
rtmp_auto_push on; # Multi-Worker
rtmp {
server {
listen 1935;
chunk_size 4096; #//数据传输块的大小
allow play all;
application live {
live on; # 启用rtmp
#publish_notify on; # 启用notify
# on_publish http://127.0.0.1/notify/publish;
# on_play http://127.0.0.1:8080/rtmp/notify/play;
# on_play_done http://127.0.0.1:8080/rtmp/notify/play_done;
# on_publish_done http://127.0.0.1/notify/publish_done;
# on_record_done http://127.0.0.1:8080/rtmp/notify/record_done;
# on_update http://127.0.0.1:8080/rtmp/notify/update;
hls on; # 启用hls
wait_key on; #对视频切片进行保护,这样就不会产生马赛克了
hls_path /www/web/default/live; #切片视频文件存放位置
hls_fragment 10s; #每个视频切片的时长
hls_continuous on; #连续模式
hls_cleanup on; #对多余的切片进行删
# hls_plahls_nested on; #嵌套模式
record all;
record_path /www/web/default/vod; # 录制保存地址
#record_append on;
record_unique on;
#record keyframes;
#record_path /www/web/default/vod;
#record_max_frames 100;
#record_interval 20m;
#exec /usr/local/ffmpeg-3.4-64bit-static/ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name;
# 跟踪客户信息
exec_play bash -c "echo $addr $pageurl >> /tmp/clients";
exec_publish bash -c "echo $addr $flashver >> /tmp/publishers";
# 转换录制的文件格式的MP4
# exec_record_done /usr/local/ffmpeg-3wp:4-64bit-static/ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;
}
# application live360p {
# live on;
# hls on; # 启用hls
# hls_path /home/live360p;
# record off;
# allow publish 127.0.0.1;
# deny publish all;
# }
}
}
在http{}前
8、nginx相关命令
/usr/local/nginx/sbin/nginx -s reload #重载配置
/usr/local/nginx/sbin/nginx -s stop #停止
/usr/local/nginx/sbin/nginx #开启
9、添加端口开放
firewall-cmd --query-port=1935/tcp
firewall-cmd --permanent --zone=public --add-port=1935/tcp
systemctl restart firewalld.service
10、设置开机启动
vi /lib/systemd/system/nginx.service
服务代码描述:
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
保存后重载下服务
systemctl daemon-reload
命令详解:
systemctl enable nginx.service #启动服务
systemctl status nginx.service #查看服务状态
systemctl start nginx.service #开启服务
systemctl stop nginx.service #停止服务
systemctl restart nginx.service #重启服务
11、检查推流端口是否正常
cmd
telnet 140.143.157.56 1935
12、直播目录
live /www/web/default/live
vod /www/web/default/vod
13、推流地址
直播地址:rtmp://140.143.157.56/live/
串码:1111
用惯了windows的人,会习惯性地按Ctrl+S来保存,
当你在使用vi insert 保存应该用 命令模式--wq退出 而不是ctrl+s
估计你就是这么做的.
而该举动在vi中的结果就是将vi冻住
用Ctrl+Q可以解冻
1、添加Nginx存储库
sudo yum install epel-release
2、安装Nginx
sudo yum install nginx
3、启动Nginx
sudo systemctl start nginx
4、添加到防火墙
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
注意:firewall is not running
这里启动下防火墙
systemctl start firewalld
开放端口
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-port=23560/tcp
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=33481/tcp
5、安装成功后的Nginx地址
/usr/share/nginx/html/ 站点目录
/etc/nginx/conf.d/ 自定义Nginx站点配置文件存放目录
/etc/nginx/nginx.conf 全局配置
nginx -c nginx.confN ginx启动
6、查看nginx版本
nginx -V
查看到是:nginx/1.12.2
返回到Nginx的目录
cd /usr/share/
停止Nginx
systemctl stop nginx
启动Nginx
systemctl start nginx
卸载Nginx
yum remove nginx