本文整理汇总了PHP中wp_file_get_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_file_get_contents函数的具体用法?PHP wp_file_get_contents怎么用?PHP wp_file_get_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_file_get_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
if ($_REQUEST['doNotInit']) {
return true;
}
$content = wp_file_get_contents('php://input');
!empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
if ($_GET['encrypt_type'] == 'aes') {
vendor('WXBiz.wxBizMsgCrypt');
$this->sReqTimeStamp = I('get.timestamp');
$this->sReqNonce = I('get.nonce');
$this->sEncryptMsg = I('get.msg_signature');
$map['id'] = I('get.id');
$info = M('member_public')->where($map)->find();
get_token($info['token']);
// 设置token
$this->wxcpt = new \WXBizMsgCrypt('weiphp', $info['encodingaeskey'], $info['appid']);
$sMsg = "";
// 解析之后的明文
$errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
if ($errCode != 0) {
addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
exit;
} else {
// 解密成功,sMsg即为xml格式的明文
$content = $sMsg;
}
}
$data = new \SimpleXMLElement($content);
// $data || die ( '参数获取失败' );
foreach ($data as $key => $value) {
$this->data[$key] = strval($value);
}
}
示例2: uploadCert
function uploadCert($fileId)
{
$managerId = $this->mid;
$path = SITE_PATH . '\\Cert\\wxzf\\' . $managerId;
$file = M('file')->find($fileId);
$file['savepath'] = substr($file['savepath'], 0, strlen($file['savepath']) - 1);
$filename = SITE_PATH . '\\Uploads\\Download\\' . $file['savepath'] . '\\' . $file['savename'];
// dump($file);
// dump($filename);
// dump(file_exists($filename));
// die;
if (!file_exists($filename)) {
$this->error('上传失败');
exit;
}
// $extend = $file ['ext'];
// if (! ($extend == 'pem' || $extend == 'p12' )) {
// $this->error('上传证书格式有误,扩展名应为 pem');
// exit();
// }
$mkres = mkdirs($path);
$content = wp_file_get_contents($filename);
$res = file_put_contents($path . '\\' . $file['name'], $content);
return $res;
}
示例3: _thumb_media_id
function _thumb_media_id($cover_id)
{
$cover = get_cover($cover_id);
$driver = C('PICTURE_UPLOAD_DRIVER');
if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
// 先把图片下载到本地
$pathinfo = pathinfo(SITE_PATH . $cover['path']);
mkdirs($pathinfo['dirname']);
$content = wp_file_get_contents($cover['url']);
$res = file_put_contents(SITE_PATH . $cover['path'], $content);
if ($res) {
return '';
}
}
$path = $cover['path'];
if (!$path) {
return '';
}
$param['type'] = 'thumb';
$param['media'] = '@' . realpath(SITE_PATH . $path);
$url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
$res = post_data($url, $param, true);
if (isset($res['errcode']) && $res['errcode'] != 0) {
return '';
}
$map['cover_id'] = $cover_id;
$map['manager_id'] = $this->mid;
$this->where($map)->setField('thumb_media_id', $res['media_id']);
return $res['media_id'];
}
示例4: getRemoteVersion
function getRemoteVersion()
{
// cookie ( 'cookie_close_version', 0 );
$remote = 'http://www.weiphp.cn/index.php?s=/home/index/update_version';
$new_version = wp_file_get_contents($remote);
$res = $new_version > C('SYSTEM_UPDATRE_VERSION') && cookie('cookie_close_version') != $new_version;
echo $res ? $new_version : 0;
}
示例5: get_content_by_url_id
private function get_content_by_url_id($id)
{
$url = "http://job.snnu.edu.cn/com/show_info.asp?com_id={$id}&com_version=0&action=com_info";
$source = wp_file_get_contents($url);
$s = mb_convert_encoding($source, "UTF-8", "GB18030");
preg_match_all("/<div id=attitle>([^>]+)<\\/div>/i", $s, $_title);
// preg_match_all("/<div id=dwinfor align=\"center\">([^\n]+).*/i", $s, $_subContent);
// preg_match_all("/<FONT style=([^\n]+).*/i", $s, $_mainContent);
$title = trim($_title[1][0]);
// $content = $_subContent[0][0].$_mainContent[0][0];
return array("title" => $title, "url" => $url);
}
示例6: __construct
public function __construct()
{
if ($_REQUEST['doNotInit']) {
return true;
}
$content = wp_file_get_contents('php://input');
!empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
if ($_GET['encrypt_type'] == 'aes') {
vendor('WXBiz.wxBizMsgCrypt');
$this->sReqTimeStamp = I('get.timestamp');
$this->sReqNonce = I('get.nonce');
$this->sEncryptMsg = I('get.msg_signature');
if (isset($_GET['appid'])) {
// if ($_GET ['appid'] == 'wx570bc396a51b8ff8') {
// $info ['token'] = 'gh_3c884a361561';
// $info ['encodingaeskey'] = 'DfEqNBRvzbg8MJdRQCSGyaMp6iLcGOldKFT0r8I6Tnp';
// $info ['appid'] = 'wxea0485bef5247236';
// } else {
// $map ['appid'] = I ( 'get.appid' );
// $info = D ( 'Common/Public' )->where ( $map )->find ();
// }
$map['appid'] = I('get.appid');
$info = D('Common/Public')->where($map)->find();
} else {
$id = I('get.id');
$info = D('Common/Public')->getInfo($id);
}
get_token($info['token']);
// 设置token
$this->wxcpt = new \WXBizMsgCrypt($info['mp_token'], $info['encodingaeskey'], $info['appid']);
$sMsg = "";
// 解析之后的明文
$errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
if ($errCode != 0) {
addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
addWeixinLog($content, "DecryptMsg Error: content");
exit;
} else {
// 解密成功,sMsg即为xml格式的明文
$content = $sMsg;
}
}
$data = new \SimpleXMLElement($content);
// $data || die ( '参数获取失败' );
foreach ($data as $key => $value) {
$this->data[$key] = safe(strval($value));
}
}
示例7: __construct
public function __construct()
{
if ($_REQUEST['doNotInit']) {
return true;
}
$content = wp_file_get_contents('php://input');
!empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
if ($_GET['encrypt_type'] == 'aes') {
vendor('WXBiz.wxBizMsgCrypt');
$this->sReqTimeStamp = I('get.timestamp');
$this->sReqNonce = I('get.nonce');
$this->sEncryptMsg = I('get.msg_signature');
if (isset($_GET['appid'])) {
$map['appid'] = I('get.appid');
$info = D('Common/Public')->where($map)->find();
} else {
$id = I('get.pid');
$info = D('Common/Public')->getInfo($id);
}
$info['encodingaeskey'] = 'Wry3C6IG6yzFR55cnje0W7CWd2jqlqQrAIK5ilOIfo3';
$info['appid'] = D('Addons://PublicBind/PublicBind')->component_appid;
get_token($info['token']);
// 设置token
$this->wxcpt = new \WXBizMsgCrypt('youkang120', $info['encodingaeskey'], $info['appid']);
$sMsg = "";
// 解析之后的明文
$errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
if ($errCode != 0) {
addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
addWeixinLog($content, "DecryptMsg Error: content");
exit;
} else {
// 解密成功,sMsg即为xml格式的明文
$content = $sMsg;
}
}
$data = new \SimpleXMLElement($content);
// $data || die ( '参数获取失败' );
foreach ($data as $key => $value) {
$this->data[$key] = safe(strval($value));
}
}
示例8: tongbuyonghuhao
public function tongbuyonghuhao()
{
//同步用户号
$token = get_token();
$access_token = get_access_token($token);
$url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . $access_token . '';
$users = json_decode(wp_file_get_contents($url), true);
if (!$users['total']) {
$this->error("更新失败");
}
$data = $users['data'];
$openidArray = $data['openid'];
foreach ($openidArray as $key => $openid) {
$userInfo = getWeixinUserInfo($openid, $token);
$map['openid'] = $userInfo['openid'];
$data['nickname'] = $userInfo['nickname'];
$data['sex'] = $userInfo['sex'];
$data['city'] = $userInfo['city'];
$data['country'] = $userInfo['country'];
$data['province'] = $userInfo['province'];
$data['language'] = $userInfo['language'];
$data['headimgurl'] = $userInfo['headimgurl'];
$data['subscribe_time'] = $userInfo['subscribe_time'];
$data['status'] = $userInfo['subscribe'];
$data['token'] = $token;
$result_id = M('Follow')->where($map)->getField('id');
if ($result_id) {
//更新
$data['id'] = $result_id;
M('Follow')->save($data);
unset($data);
} else {
//新增
D('Common/Follow')->init_follow($userInfo['openid']);
}
}
$this->success("同步完成!");
}
示例9: getSendInfo
function getSendInfo($id)
{
$info = $this->getInfo($id);
$map['id'] = $info['shop_id'];
$api_key = M('shop')->where($map)->getField('api_key');
empty($api_key) && ($api_key = '02727dd96ccf4c4eabb091d85cb7fa10');
$url = 'http://v.juhe.cn/exp/index?key=' . $api_key . '&com=' . $info['send_code'] . '&no=' . $info['send_number'];
$data = wp_file_get_contents($url);
$data = json_decode($data, true);
if ($data['resultcode'] == 200) {
$save['order_id'] = $id;
$save['status_code'] = 3;
$save['extend'] = 1;
M('shop_order_log')->where($save)->delete();
foreach ($data['result']['list'] as $vo) {
$save['cTime'] = strtotime($vo['datetime']);
$save['remark'] = $vo['zone'] . ' ' . $vo['remark'];
M('shop_order_log')->add($save);
}
}
return $data;
}
示例10: _updateWechatGroup
function _updateWechatGroup()
{
// 先取当前用户组数据
$map['token'] = get_token();
$map['manager_id'] = $this->mid;
$map['type'] = 1;
$group_list = M('auth_group')->where($map)->getField('wechat_group_id,id');
$url = 'https://api.weixin.qq.com/cgi-bin/groups/get?access_token=' . get_access_token();
$data = wp_file_get_contents($url);
$data = json_decode($data, true);
foreach ($data['groups'] as $d) {
if (isset($group_list[$d['id']])) {
continue;
}
$map['wechat_group_id'] = $d['id'];
$map['wechat_group_name'] = $d['name'];
$map['wechat_group_count'] = $d['count'];
// 增加本地数据
$map['title'] = $d['name'];
$map['qr_code'] = '';
M('auth_group')->add($save);
}
}
示例11: syc_openid
function syc_openid()
{
error_log('第一步:获取全部用户的ID,并先保存到public_follow表中,新的用户UID暂时为0,后面的步骤补充');
// 获取openid列表
$url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . get_access_token() . '&next_openid=' . I('next_openid');
$data = wp_file_get_contents($url);
$data = json_decode($data, true);
if (!isset($data['count']) || $data['count'] == 0) {
// 拉取完毕
$this->success('同步用户数据中,请勿关闭', U('syc_user'));
exit;
}
$map['openid'] = array('in', $data['data']['openid']);
$map['token'] = $save['token'] = get_token();
$res = M('public_follow')->where($map)->setField('syc_status', 0);
if ($res != $data['count']) {
// 更新的数量不一致,可能有增加的用户openid
$openids = (array) M('public_follow')->where($map)->getFields('openid');
$diff = array_diff($data['data']['openid'], $openids);
if (!empty($diff)) {
foreach ($diff as $id) {
$save['openid'] = $id;
$save['uid'] = 0;
$save['syc_status'] = 0;
$res = M('public_follow')->add($save);
}
}
}
$param2['next_openid'] = $data['next_openid'];
$url = U('syc_openid', $param2);
$this->success('同步用户OpenID中,请勿关闭', $url);
}
示例12: updateWechatGroup
function updateWechatGroup()
{
error_log('与微信的用户组保持同步');
// 先取当前用户组数据
$map['token'] = get_token();
$map['manager_id'] = $this->mid;
$map['type'] = 1;
$group_list = M('auth_group')->where($map)->field('id,title,wechat_group_id,wechat_group_name,wechat_group_count')->select();
foreach ($group_list as $g) {
$groups[$g['wechat_group_id']] = $g;
}
$url = 'https://api.weixin.qq.com/cgi-bin/groups/get?access_token=' . get_access_token();
$data = wp_file_get_contents($url);
$data = json_decode($data, true);
if (!isset($data['errcode'])) {
foreach ($data['groups'] as $d) {
$save['wechat_group_id'] = $map['wechat_group_id'] = $d['id'];
$save['wechat_group_name'] = $d['name'];
$save['wechat_group_count'] = $d['count'];
if (isset($groups[$d['id']])) {
// 更新本地数据
$old = $groups[$d['id']];
if ($old['title'] != $d['name']) {
$old['wechat_group_name'] = $old['title'];
$save['wechat_group_name'] = $old['title'];
//修改微信端的数据
$updateUrl = "https://api.weixin.qq.com/cgi-bin/groups/update?access_token=" . get_access_token();
$newGroup['group']['id'] = $d['id'];
$newGroup['group']['name'] = $save['wechat_group_name'];
$res = post_data($updateUrl, $newGroup);
}
if ($old['wechat_group_name'] != $d['name'] || $old['wechat_group_count'] != $d['count']) {
// $save['title']=$save['wechat_group_name'];
M('auth_group')->where($map)->save($save);
}
unset($groups[$d['id']]);
} else {
// 增加本地数据
$save = array_merge($save, $map);
$save['title'] = $d['name'];
$save['qr_code'] = '';
M('auth_group')->add($save);
}
}
foreach ($groups as $v) {
$map2['id'] = $map3['group_id'] = $v['id'];
$wechat_group_id = intval($v['wechat_group_id']);
if ($wechat_group_id == -1) {
// 增加微信端的数据
$url = 'https://api.weixin.qq.com/cgi-bin/groups/create?access_token=' . get_access_token();
$param['group']['name'] = $v['title'];
$param = JSON($param);
$res = post_data($url, $param);
if (!empty($res['group']['id'])) {
$info['wechat_group_id'] = $save['wechat_group_id'] = $res['group']['id'];
$save['wechat_group_name'] = $res['group']['name'];
M('auth_group')->where($map2)->save($save);
}
} else {
// 删除本地数据
M('auth_group')->where($map2)->delete();
M('auth_group_access')->where($map3)->delete();
}
}
}
if (isset($_GET['need_return'])) {
redirect(addons_url('UserCenter://UserCenter/syc_openid'));
}
}
示例13: init
/**
* 初始化微信推送的数据
*/
private function init()
{
$xml = wp_file_get_contents("php://input");
$data = self::xml2data($xml);
//安全模式 或兼容模式
if (self::$msgSafeMode) {
if (isset($data['MsgType'])) {
//兼容模式追加解密后的消息内容
$data['Decrypt'] = self::extract($data['Encrypt']);
} else {
//安全模式
$data = self::extract($data['Encrypt']);
}
}
$this->data = $data;
}
示例14: _footer
function _footer($temp_type = 'weiphp')
{
if ($temp_type == 'pigcms') {
$param['token'] = $token = get_token();
$param['temp'] = $this->config['template_footer'];
$url = U('Home/Index/getFooterHtml', $param);
$html = wp_file_get_contents($url);
// dump ( $url );
// dump ( $html );
$file = RUNTIME_PATH . $token . '_' . $this->config['template_footer'] . '.html';
if (!file_exists($file) || true) {
file_put_contents($file, $html);
}
$this->assign('cateMenuFileName', $file);
} else {
$list = D('Addons://WeiSite/Footer')->get_list();
foreach ($list as $k => $vo) {
if ($vo['pid'] != 0) {
continue;
}
$one_arr[$vo['id']] = $vo;
unset($list[$k]);
}
foreach ($one_arr as &$p) {
$two_arr = array();
foreach ($list as $key => $l) {
if ($l['pid'] != $p['id']) {
continue;
}
$two_arr[] = $l;
unset($list[$key]);
}
$p['child'] = $two_arr;
}
$this->assign('footer', $one_arr);
$html = $this->fetch(ONETHINK_ADDON_PATH . 'WeiSite/View/default/TemplateFooter/' . $this->config['template_footer'] . '/footer.html');
$this->assign('footer_html', $html);
}
}
示例15: init_follow
private function init_follow($data)
{
$info = get_token_appinfo($data['ToUserName']);
$config = S('PUBLIC_AUTH_' . $info['type']);
if (!$config) {
$config = M('public_auth')->getField('name,type_' . $info['type'] . ' as val');
S('PUBLIC_AUTH_' . $info['type'], $config, 86400);
}
C($config);
// 公众号接口权限
// 初始化用户信息
$map['token'] = $data['ToUserName'];
$map['openid'] = $data['FromUserName'];
$GLOBALS['mid'] = $uid = M('public_follow')->where($map)->getField('uid');
// 绑定配置
$config = getAddonConfig('UserCenter', $map['token']);
if (!$uid && C('USER_BASE_INFO')) {
// 如果有权限获取用户信息,即自动获取
$url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . get_access_token() . '&openid=' . $data['FromUserName'] . '&lang=zh_CN';
$userInfo = wp_file_get_contents($url);
$userInfo = json_decode($userInfo, true);
if (isset($userInfo['nickname'])) {
// 自动注册
$user = array('experience' => intval($config['experience']), 'score' => intval($config['score']), 'reg_ip' => get_client_ip(1), 'reg_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), 'last_login_time' => NOW_TIME, 'status' => 1, 'is_init' => 1, 'is_audit' => 1);
$user = array_merge($user, $userInfo);
$map['uid'] = $uid = D('Common/User')->add($user);
$res = M('public_follow')->add($map);
}
}
$guestAccess = strtolower(CONTROLLER_NAME) != 'weixin';
$userNeed = $user['uid'] > 0 && $user['status'] < 2 || empty($user) && $guestAccess;
if ($config['need_bind'] == 1 && $userNeed && C('USER_OAUTH')) {
unset($map['uid']);
$bind_url = addons_url('UserCenter://Wap/bind', $map);
if ($config['bind_start'] != 0 && strtolower($data['Event']) != 'subscribe') {
$dao->replyText('请先<a href="' . $bind_url . '">绑定账号</a>再使用');
exit;
}
}
}