前公司吃饭是需要在钉钉报餐的,对于不挑剔的我每天都在公司吃饭,有时忘记报餐导致吃不了饭还是很麻烦的。看了下报餐系统需要的是json数据包含我的工号即可。于是编写如下代码,放在360网址监控,1小时执行1次
<?php
/*自动报餐类*/
class AutoBaocan{
private $url;
private $data;
//构造方法初始化
function __construct($url,$data){
$this->url=$url;
$this->data=$data;
}
//(1).创建会话,返回会话
public function newcurl(){
$ch=curl_init();//初始会话
curl_setopt($ch,CURLOPT_POST,1);/*Post模式*/
curl_setopt($ch,CURLOPT_URL,$this->url);/*URl设置*/
curl_setopt($ch,CURLOPT_POSTFIELDS,$this->data);/*Json数据*/
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
'Content-Type: application/json; charset=gb2312',
'Content-Length: ' . strlen($this->data)
));
return $ch;
}
//(2).利用会话句柄,发送Json,返回状态和文本
public function postjson($ch){
//开启缓存区
ob_start();
//执行CURL会话
curl_exec($ch);
//获取缓冲区的内容
$return_content=ob_get_contents();
//关闭缓冲区
ob_end_clean();
//获取资源句柄的信息
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return array($return_code, $return_content);
}
}
/*类结束*/
//设置参数
$url = "http://weixin.xajlnkyjy.com/lswyjishu/renshi.php/Bcdingding/baocan"; /*目标URL*/
$info = array
(
shangwu=>'吃',
xiawu=>'吃',
jobnumber=>'0209060334387389791',
ename=>'高久峰',
deptname=>'安康项目组'
);
$data = json_encode($info);/*Json数据*/
//实例化
$Baocan=new AutoBaocan($url,$data);
//执行发送json
$result=$Baocan->postjson($Baocan->newcurl());
//生成日志
file_put_contents('log.txt',$result[0]."--".$result[1]."\r\n",FILE_APPEND);
?> 因项目需要需要统计用户无限下级计算分销佣金,计算每月分红,计算无限下级团队的业绩,需要先获得某个会员的无限下级成员。先看看数据库中的member表字段id username &...
ThinkPHP中有一个debug调试功能,能输出报错文件的信息,并能看到这个函数被哪些函数调用,从框架的启动开始记录,特别方便调试。于是研究了下它的底层给予了实现。<?php //--框架核心--Start //框架内置错误处理 function errDealWith($er...
参数中包含gb2312的字符串,返回结果是false或者null(不同PHP版本具有差异性)代码:<?php $dbms = 'mysql'; $host = '192.168.8.8'; $dbName =&n...
今天帮朋友查询wordpress执行超级慢的原因,特此记录开启fpm的慢日志,记录执行超过30秒的脚本request_slowlog_timeout = 30 slowlog = var/log/slow.log查看日志[23-May-2019 17...
<?php //如果支持exec函数,可以使用的方式 exec('chcp 65001'); //如果exec函数因安全问题禁用,可以使用的方式 pclose(popen('chcp 65001', 'r'));...
概念请参考w3school文章: redis watch ,redis exec (看完基本秒懂)(1)基本事务://连接本地的 Redis 服务 $redis = new Redis(); $redis->con...