本文整理汇总了PHP中Http::curlPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::curlPost方法的具体用法?PHP Http::curlPost怎么用?PHP Http::curlPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::curlPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
import('Http');
$result = Http::curlPost($this->apiUrl . 'index.php?g=Home&m=Links&a=index&auth=1', array('token' => $this->token));
if ($result['status'] == 1) {
$this->assign('data', $result['data']);
$this->display();
} else {
echo $result['msg'];
}
}
示例2: send
public function send()
{
if (IS_GET) {
$id = isset($_GET['send']) ? intval($_GET['send']) : 0;
if (empty($id)) {
$this->error('没有发送内容');
}
$log = D('Send_log')->where(array('pigcms_id' => $id))->find();
if (empty($log)) {
$this->error('没有发送内容');
}
$user = D('Send_user')->where(array('log_id' => $id, 'status' => 0))->find();
if (empty($user)) {
D('Send_log')->where(array('pigcms_id' => $id))->save(array('status' => 1));
$this->success('发送完成', U('Send/index'));
exit;
}
$source = D('Source_material')->where(array('pigcms_id' => $log['c_id']))->find();
if (empty($source)) {
$this->error('没有发送内容');
}
$ids = unserialize($source['it_ids']);
$image_text = D('Image_text')->field(true)->where(array('pigcms_id' => array('in', $ids)))->select();
$str = '{"touser":"' . $user['openid'] . '","msgtype":"news","news":{"articles": [';
$pre = '';
foreach ($image_text as $txt) {
$url = $this->config['site_url'] . '/wap.php?g=Wap&c=Article&a=index&imid=' . $txt['pigcms_id'];
$str .= $pre . '{"title":"' . $txt['title'] . '", "description":"' . $txt['digest'] . '", "url":"' . $url . '", "picurl":"' . $this->config['site_url'] . $txt['cover_pic'] . '"}';
$pre = ',';
}
$str .= ']}}';
$access_token_array = D('Access_token_expires')->get_access_token();
if ($access_token_array['errcode']) {
$this->error('获取access_token发生错误:错误代码' . $access_token_array['errcode'] . ',微信返回错误信息:' . $access_token_array['errmsg']);
}
$access_token = $access_token_array['access_token'];
$url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token;
import('ORG.Net.Http');
$rt = Http::curlPost($url, $str);
if ($rt['errcode']) {
D('Send_user')->where(array('log_id' => $id, 'openid' => $user['openid']))->save(array('status' => 2, 'sendtime' => time()));
} else {
D('Send_user')->where(array('log_id' => $id, 'openid' => $user['openid']))->save(array('status' => 1, 'sendtime' => time()));
}
$this->success('不要关闭窗口,发送还在进行中...', U('Send/send', array('send' => $id)));
exit;
} else {
$this->error('非法操作');
}
}
示例3: get_access_token
public function get_access_token($mer_id)
{
$weixin_bind = $this->where(array('mer_id' => $mer_id))->find();
if (empty($weixin_bind)) {
return array('errcode' => 1, 'errmsg' => '公众授权异常,请重新授权');
}
$access_token = $_SESSION['authorizer_access_token'];
//session('authorizer_access_token');$_SESSION['authorizer_access_token']
if ($access_token && $access_token[0] > time()) {
$authorizer_access_token = $access_token[1];
} else {
import('ORG.Net.Http');
$result = $_SESSION['component_access_token'];
//session('component_access_token');
if ($result && $result[0] > time()) {
$component_access_token = $result[1];
} else {
//获取component_access_token
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
$data = array('component_appid' => C('config.wx_appid'), 'component_appsecret' => C('config.wx_appsecret'), 'component_verify_ticket' => C('config.wx_componentverifyticket'));
$result = Http::curlPost($url, json_encode($data));
if ($result['errcode']) {
return $result;
} else {
$component_access_token = $result['component_access_token'];
}
}
//利用刷新token 获取 authorizer_access_token
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=' . $component_access_token;
$data = array();
$data['component_appid'] = C('config.wx_appid');
$data['authorizer_appid'] = $weixin_bind['authorizer_appid'];
$data['authorizer_refresh_token'] = $weixin_bind['authorizer_refresh_token'];
$access_data = Http::curlPost($url, json_encode($data));
if ($access_data['errcode']) {
return $access_data;
} else {
$authorizer_access_token = $access_data['authorizer_access_token'];
$_SESSION['authorizer_access_token'] = array($access_data['expires_in'] + time(), $access_data['authorizer_access_token']);
}
}
return array('errcode' => 0, 'access_token' => $authorizer_access_token);
}
示例4: get_component_access_token
public function get_component_access_token($store_id)
{
import('source.class.Http');
$component_access_tokenName = $store_id . '_component_access_token';
$result = S($component_access_tokenName);
if ($result && $result[0] > time()) {
return $result[1];
} else {
//获取component_access_token
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
$data = array('component_appid' => option('config.wx_appid'), 'component_appsecret' => option('config.wx_appsecret'), 'component_verify_ticket' => option('config.wx_componentverifyticket'));
$result = Http::curlPost($url, json_encode($data));
if ($result['errcode']) {
return $result;
} else {
S($component_access_tokenName, array($result['expires_in'] + time(), $result['component_access_token']), $result['expires_in'] + time());
return $result['component_access_token'];
}
}
}
示例5: im
public function im()
{
if (empty($this->config['site_url'])) {
exit(json_encode(array('error_code' => true, 'msg' => '先填写您网站的域名')));
}
if (empty($this->config['wechat_appid']) || empty($this->config['wechat_appsecret'])) {
exit(json_encode(array('error_code' => true, 'msg' => '先设置站点的微信公众号信息')));
}
$array = parse_url($this->config['site_url']);
$host = $array['host'];
import('ORG.Net.Http');
$http = new Http();
$data = array('domain' => $host, 'label' => '', 'from' => '2', 'wx_app_id' => $this->config['wechat_appid'], 'wx_app_secret' => $this->config['wechat_appsecret'], 'activity_url' => $this->config['site_url'] . '/wap.php?g=Wap&c=Api&a=activity', 'my_url' => $this->config['site_url'] . '/wap.php?g=Wap&c=Api&a=my', 'msg_tip_url' => $this->config['site_url'] . '/wap.php?g=Wap&c=Api&a=index');
$return = Http::curlPost('http://im-link.meihua.com/api/app_create.php', $data);
if ($return['err_code']) {
exit(json_encode(array('error_code' => true, 'msg' => $return['err_msg'])));
} else {
if (D('Config')->where('`name`=\'im_appid\'')->find()) {
D('Config')->where('`name`=\'im_appid\'')->save(array('value' => $return['app_id']));
} else {
D('Config')->add(array('name' => 'im_appid', 'value' => $return['app_id'], 'gid' => 0, 'status' => 1));
}
if (D('Config')->where('`name`=\'im_appkey\'')->find()) {
D('Config')->where('`name`=\'im_appkey\'')->save(array('value' => $return['app_key']));
} else {
D('Config')->add(array('name' => 'im_appkey', 'value' => $return['app_key'], 'gid' => 0, 'status' => 1));
}
S(C('now_city') . 'config', NULL);
exit(json_encode(array('error_code' => false, 'msg' => '获取成功')));
}
}
示例6: reply
private function reply($data)
{
$keyword = isset($data['Content']) ? $data['Content'] : (isset($data['EventKey']) ? $data['EventKey'] : '');
if ($data['ToUserName'] == 'gh_3c884a361561') {
if ($data['MsgType'] == 'event') {
return array($data['Event'] . 'from_callback', 'text');
}
if ($keyword == 'TESTCOMPONENT_MSG_TYPE_TEXT') {
return array('TESTCOMPONENT_MSG_TYPE_TEXT_callback', 'text');
}
if (strstr($keyword, 'QUERY_AUTH_CODE:')) {
$t = explode(':', $keyword);
$query_auth_code = $t[1];
$access_token = $this->get_access_token($query_auth_code);
$url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token;
$str = '{"touser":"' . $data['FromUserName'] . '", "msgtype":"text", "text":{"content":"' . $query_auth_code . '_from_api"}}';
import('ORG.Net.Http');
Http::curlPost($url, $str);
}
}
$mer_id = 0;
if ($bind = D('Weixin_bind')->where(array('user_name' => $data['ToUserName']))->find()) {
$mer_id = $bind['mer_id'];
} else {
return false;
}
if ($data['MsgType'] == 'event') {
$id = $data['EventKey'];
switch (strtoupper($data['Event'])) {
case 'SCAN':
return $this->scan($id, $data['FromUserName'], $mer_id);
break;
case 'CLICK':
$return = $this->special_keyword($id, $data, $mer_id);
return $return;
break;
case 'SUBSCRIBE':
$this->route();
if (isset($data['Ticket'])) {
$id = substr($data['EventKey'], 8);
return $this->scan($id, $data['FromUserName'], $mer_id);
}
if ($mer_id) {
if ($other = D('Reply_other')->where(array('type' => 0, 'mer_id' => $mer_id))->find()) {
if ($other['reply_type'] == 0) {
return array($other['content'], 'text');
} else {
return $this->txt_img($other['from_id'], $mer_id);
}
} else {
return array("感谢您的关注,我们将竭诚为您服务!", 'text');
}
}
$first = D("First")->field(true)->find();
if ($first) {
if ($first['type'] == 0) {
return array($first['content'], 'text');
} elseif ($first['type'] == 1) {
$return[] = array($first['title'], $first['info'], $this->config['site_url'] . $first['pic'], $first['url']);
} elseif ($first['type'] == 2) {
if ($first['fromid'] == 1) {
return $this->special_keyword('首页', $data);
} elseif ($first['fromid'] == 2) {
return $this->special_keyword($this->config['group_alias_name'], $data);
} else {
return $this->special_keyword($this->config['meal_alias_name'], $data);
}
} elseif ($first['type'] == 3) {
$group_list = D('Group')->field(true)->order('index_sort DESC')->limit('0, 9')->select();
$group_image_class = new group_image();
foreach ($group_list as $g) {
$tmp_pic_arr = explode(';', $g['pic']);
$image = $group_image_class->get_image_by_path($tmp_pic_arr[0], 's');
$return[] = array('[' . $this->config['group_alias_name'] . ']' . $g['s_name'], $g['name'], $image, $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=detail&group_id={$g['group_id']}");
}
return array($return, 'news');
}
} else {
return array("感谢您的关注,我们将竭诚为您服务!", 'text');
}
break;
case 'UNSUBSCRIBE':
$this->route();
return array("BYE-BYE", 'text');
break;
case 'LOCATION':
if ($long_lat = D("User_long_lat")->field(true)->where(array('open_id' => $data['FromUserName']))->find()) {
D("User_long_lat")->where(array('open_id' => $data['FromUserName']))->save(array('long' => $data['Longitude'], 'lat' => $data['Latitude'], 'dateline' => time()));
} else {
D("User_long_lat")->add(array('long' => $data['Longitude'], 'lat' => $data['Latitude'], 'dateline' => time(), 'open_id' => $data['FromUserName']));
}
break;
default:
//return array("亲,此号暂停测试,请搜索【pigcms】进行关注测试", 'text');
}
} elseif ($data['MsgType'] == 'text') {
$content = $data['Content'];
if (strtolower($content) == 'go') {
$t_data = $this->route();
// header("Content-type: text/xml");
//.........这里部分代码省略.........
示例7: get_tmp_qrcode
public function get_tmp_qrcode($qrcode_id)
{
$appid = C('config.wechat_appid');
$appsecret = C('config.wechat_appsecret');
if (empty($appid) || empty($appsecret)) {
return array('error_code' => true, 'msg' => '请联系管理员配置【AppId】【 AppSecret】');
}
import('ORG.Net.Http');
$http = new Http();
//微信授权获得access_token
$access_token_array = D('Access_token_expires')->get_access_token();
if ($access_token_array['errcode']) {
return array('error_code' => true, 'msg' => '获取access_token发生错误:错误代码' . $access_token_array['errcode'] . ',微信返回错误信息:' . $access_token_array['errmsg']);
}
$access_token = $access_token_array['access_token'];
$qrcode_url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $access_token;
$post_data['expire_seconds'] = 604800;
$post_data['action_name'] = 'QR_SCENE';
$post_data['action_info']['scene']['scene_id'] = $qrcode_id;
$json = $http->curlPost($qrcode_url, json_encode($post_data));
if (!$json['errcode']) {
return array('error_code' => false, 'id' => $qrcode_id, 'ticket' => 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . urlencode($json['ticket']));
} else {
return array('error_code' => true, 'msg' => '发生错误:错误代码 ' . $json['errcode'] . ',微信返回错误信息:' . $json['errmsg']);
}
}
示例8: fwrite
fwrite($fp, ' \'mysql_host\' => \'' . $_POST['mysql_host'] . '\', ' . "\n");
fwrite($fp, ' \'mysql_user\' => \'' . $_POST['mysql_user'] . '\', ' . "\n");
fwrite($fp, ' \'mysql_pass\' => \'' . $_POST['mysql_pass'] . '\', ' . "\n");
fwrite($fp, ' \'mysql_db\' => \'' . $_POST['mysql_db'] . '\', ' . "\n");
fwrite($fp, '); ' . "\n\n");
fwrite($fp, '?>');
fclose($fp);
$adminPassword = $_POST["admin_pwd"];
require_once 'db.php';
mysql_close($dbl);
$index = 'http://demila.org/';
require_once '../classes/Http.class.php';
$http = new Http();
$url = $index . '/statistics';
$data = array('ip' => $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'], 'domain' => $_SERVER['HTTP_HOST'], 'mobile' => $_POST['admin_phone'], 'email' => $_POST['admin_mail'], 'server' => strpos($_SERVER['SERVER_SOFTWARE'], 'PHP') === false ? $_SERVER['SERVER_SOFTWARE'] . 'PHP/' . phpversion() : $_SERVER['SERVER_SOFTWARE'], 'os' => PHP_OS);
$res = $http->curlPost($url, $data);
$complete = 'yes';
}
}
} else {
$_POST['mysql_host'] = '';
$_POST['mysql_user'] = '';
$_POST['mysql_pass'] = '';
$_POST['mysql_db'] = '';
$_POST['admin_mail'] = '';
$_POST['admin_username'] = '';
$_POST['admin_pwd'] = '';
$_POST['admin_pwd1'] = '';
$_POST['admin_phone'] = '';
$_POST['report_mail'] = '';
$_POST['meta_title'] = '';
示例9: getPrepayId
/**
* 获取prepay_id
*/
function getPrepayId()
{
// 设置接口链接
$url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
try {
// 检测必填参数
if ($this->parameters["out_trade_no"] == null) {
throw new Exception("缺少统一支付接口必填参数out_trade_no!" . "<br>");
} elseif ($this->parameters["body"] == null) {
throw new Exception("缺少统一支付接口必填参数body!" . "<br>");
} elseif ($this->parameters["total_fee"] == null) {
throw new Exception("缺少统一支付接口必填参数total_fee!" . "<br>");
} elseif ($this->parameters["notify_url"] == null) {
throw new Exception("缺少统一支付接口必填参数notify_url!" . "<br>");
} elseif ($this->parameters["trade_type"] == null) {
throw new Exception("缺少统一支付接口必填参数trade_type!" . "<br>");
} elseif ($this->parameters["trade_type"] == "JSAPI" && $this->parameters["openid"] == NULL) {
throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!" . "<br>");
}
$this->parameters["appid"] = $this->payment['wxpay_appid'];
// 公众账号ID
$this->parameters["mch_id"] = $this->payment['wxpay_mchid'];
// 商户号
$this->parameters["spbill_create_ip"] = $_SERVER['REMOTE_ADDR'];
// 终端ip
$this->parameters["nonce_str"] = $this->createNoncestr();
// 随机字符串
$this->parameters["sign"] = $this->getSign($this->parameters);
// 签名
$xml = "<xml>";
foreach ($this->parameters as $key => $val) {
if (is_numeric($val)) {
$xml .= "<" . $key . ">" . $val . "</" . $key . ">";
} else {
$xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">";
}
}
$xml .= "</xml>";
} catch (Exception $e) {
die($e->getMessage());
}
// $response = $this->postXmlCurl($xml, $url, 30);
$response = Http::curlPost($url, $xml, 30);
$result = json_decode(json_encode(simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
$prepay_id = $result["prepay_id"];
return $prepay_id;
}
示例10: send
public function send()
{
$token_data = M('Weixin_bind')->get_access_token($this->store_session['store_id']);
if ($token_data['errcode']) {
exit(json_encode($token_data));
}
$send_url = 'https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=' . $token_data['access_token'];
//内容类型
$type = isset($_POST['type']) ? intval($_POST['type']) : -1;
import('source.class.Http');
if ($type == -1) {
exit(json_encode(array('errcode' => 1, 'errmsg' => '不合法的请求')));
} else {
if ($type == 0) {
$content = $_POST['content'];
if (empty($content)) {
exit(json_encode(array('errcode' => 1, 'errmsg' => '发送内容不能为空')));
}
$str = '{"filter":{"is_to_all":true}, "text":{"content":' . $content . '}, "msgtype":"text"}';
$rt = Http::curlPost($send_url, $str);
if ($rt['errcode']) {
exit(json_encode($rt));
} else {
exit(json_encode(array('errcode' => 0, 'errmsg' => '群发成功')));
}
} elseif ($type == 1) {
$url = isset($_POST['image']) ? htmlspecialchars($_POST['image']) : '';
$url && ($url = PIGCMS_PATH . substr($url, 2));
if (empty($url) || !is_file($url)) {
exit(json_encode(array('errcode' => 1, 'errmsg' => '不是合法的图片')));
}
$upload = Http::curlPost('http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=' . $token_data['access_token'] . '&type=image', array('media' => '@' . $url));
if ($upload['errcode']) {
exit(json_encode($upload));
}
//图片
$str = '{"filter":{"is_to_all":true},"image":{"media_id":"' . $upload['media_id'] . '"}, "msgtype":"image"}';
$result = Http::curlPost($send_url, $str);
if ($result['errcode']) {
exit(json_encode($result));
} else {
exit(json_encode(array('errcode' => 0, 'errmsg' => '群发成功')));
}
} else {
$pigcms_id = isset($_POST['source_id']) ? intval($_POST['source_id']) : 0;
if ($data = D('Source_material')->where(array('pigcms_id' => $pigcms_id, 'store_id' => $this->store_session['store_id']))->find()) {
$upload_url = 'http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=' . $token_data['access_token'] . '&type=image';
$it_ids = unserialize($data['it_ids']);
$comma = $send = '';
$media = array();
if ($data['type'] == 0) {
$id = isset($it_ids[0]) ? intval($it_ids[0]) : 0;
$image_text = D('Image_text')->where(array('pigcms_id' => $id, 'store_id' => $this->store_session['store_id']))->find();
if ($image_text['cover_pic']) {
$url = PIGCMS_PATH . substr($image_text['cover_pic'], 1);
$media = Http::curlPost($upload_url, array('media' => '@' . $url));
if ($media['errcode']) {
exit(json_encode($media));
}
} else {
$media['media_id'] = '';
}
$send = '{"thumb_media_id":"' . $media['media_id'] . '","author":"' . $image_text['author'] . '","title":"' . $image_text['title'] . '","content_source_url":"' . $image_text['url'] . '","content":"' . $image_text['content'] . '","digest":"' . $image_text['digest'] . '", "show_cover_pic":"' . $image_text['is_show'] . '"}';
} else {
$image_text = D('Image_text')->where(array('pigcms_id' => array('in', $it_ids)))->order('pigcms_id asc')->select();
foreach ($image_text as $image) {
$media['media_id'] = '';
if ($image['cover_pic']) {
$url = PIGCMS_PATH . substr($image['cover_pic'], 1);
$media = Http::curlPost($upload_url, array('media' => '@' . $url));
if ($media['errcode']) {
exit(json_encode($media));
}
}
$send .= $comma . '{"thumb_media_id":"' . $media['media_id'] . '","author":"' . $image['author'] . '","title":"' . $image['title'] . '","content_source_url":"' . $image['url'] . '","content":"' . $image['content'] . '","digest":"' . $image['digest'] . '", "show_cover_pic":"' . $image['is_show'] . '"}';
$comma = ',';
}
}
$uploadnews = Http::curlPost('https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=' . $token_data['access_token'], '{"articles": [' . $send . ']}');
if ($uploadnews['errcode']) {
exit(json_encode($uploadnews));
}
$str = '{"filter":{"is_to_all":true}, "mpnews":{"media_id":"' . $uploadnews['media_id'] . '"}, "msgtype":"mpnews"}';
$result = Http::curlPost($send_url, $str);
if ($result['errcode']) {
exit(json_encode($result));
} else {
exit(json_encode(array('errcode' => 0, 'errmsg' => '群发成功')));
}
} else {
exit(json_encode(array('errcode' => 1, 'errmsg' => '不是合法的参数')));
}
}
}
}
示例11: class_send
public function class_send()
{
$token_data = D('Weixin_bind')->get_access_token($this->merchant_session['mer_id']);
if ($token_data['errcode']) {
exit(json_encode($token_data));
}
$class = D('Diymenu_class')->where(array('pid' => 0, 'mer_id' => $this->merchant_session['mer_id']))->limit(3)->order('sort asc')->select();
$kcount = D('Diymenu_class')->where(array('pid' => 0, 'mer_id' => $this->merchant_session['mer_id']))->count('id');
$k = 1;
$data = '{"button":[';
foreach ($class as $key => $vo) {
$data .= '{"name":"' . $vo['title'] . '",';
$c = D('Diymenu_class')->where(array('pid' => $vo['id'], 'mer_id' => $this->merchant_session['mer_id']))->limit(5)->order('sort asc')->select();
$count = D('Diymenu_class')->where(array('pid' => $vo['id'], 'mer_id' => $this->merchant_session['mer_id']))->count('id');
if ($c != false) {
$data .= '"sub_button":[';
} else {
if ($vo['url']) {
$data .= '"type":"view","url":"' . $vo['url'] . '"';
} else {
if ($vo['keyword']) {
$data .= '"type":"click","key":"' . $vo['keyword'] . '"';
} else {
if ($vo['wxsys'] != 0 && $vo['wxsys'] != 1) {
$data .= '"type":"' . $vo['wxsys'] . '","key":"' . $vo['wxsys'] . '"';
}
}
}
}
$i = 1;
foreach ($c as $voo) {
if ($i == $count) {
if ($voo['url']) {
$data .= '{"type":"view","name":"' . $voo['title'] . '","url":"' . $voo['url'] . '"}';
} else {
if ($voo['keyword']) {
$data .= '{"type":"click","name":"' . $voo['title'] . '","key":"' . $voo['keyword'] . '"}';
} else {
if ($voo['wxsys'] != 0 && $voo['wxsys'] != 1) {
$data .= '{"type":"' . $voo['wxsys'] . '","name":"' . $voo['title'] . '","key":"' . $voo['wxsys'] . '"}';
}
}
}
} else {
if ($voo['url']) {
$data .= '{"type":"view","name":"' . $voo['title'] . '","url":"' . $voo['url'] . '"},';
} else {
if ($voo['keyword']) {
$data .= '{"type":"click","name":"' . $voo['title'] . '","key":"' . $voo['keyword'] . '"},';
} else {
if ($voo['wxsys'] != 0 && $voo['wxsys'] != 1) {
$data .= '{"type":"' . $voo['wxsys'] . '","name":"' . $voo['title'] . '","key":"' . $voo['wxsys'] . '"},';
}
}
}
}
$i++;
}
if ($c != false) {
$data .= ']';
}
if ($k == $kcount) {
$data .= '}';
} else {
$data .= '},';
}
$k++;
}
$data .= ']}';
file_get_contents('https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=' . $token_data['access_token']);
$url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $token_data['access_token'];
import('ORG.Net.Http');
$rt = Http::curlPost($url, $data);
if ($rt['errcode']) {
return json_encode($rt);
} else {
return json_encode(array('errcode' => 0, 'errmsg' => '自定义菜单生产成功'));
}
}
示例12: strpos
define('USING_LANGUAGE', false);
require_once 'config.php';
require_once $config['root_path'] . '/core/functions.php';
include_once $config['system_core'] . "/initEngine.php";
admin_login();
header("Content-Type:text/html;charset=utf-8");
if (isset($_POST["update_version"]) && $_POST["update_version"] == 'true') {
$copyright = str_replace(' ', '', file_get_contents(TEMPLATE_PATH . 'footer.html'));
$str = $langArray['copyright_link'];
$res = strpos($copyright, $str);
if (!$res) {
require_once ROOT_PATH . '/classes/Http.class.php';
$http = new Http();
$index = 'http://demila.org/checkempower ';
$data["data"] = $_SERVER['HTTP_HOST'];
$news1 = $http->curlPost($index, $data);
$status = false;
if (strstr($news1, "true")) {
$status = true;
}
if (!$status) {
$data["msg"] = $langArray['is_copyright'];
} else {
if (substr(sprintf('%o', fileperms($_SERVER['DOCUMENT_ROOT'])), -4) != '0777') {
$data["msg"] = $langArray['update_server'];
} else {
require_once ROOT_PATH . '/classes/Http.class.php';
$http = new Http();
$url = $langArray['index'] . '/getversion';
$version = $http->curlGet($url);
$version = strstr($version, '[{');
示例13: array
}
$data_order = array();
if ($_POST['payType'] == 'offline' && $offline_payment) {
$data_order['status'] = 2;
$data_order['payment_method'] = 'codpay';
}
$condition_order['order_id'] = $nowOrder['order_id'];
$data_order['trade_no'] = $trade_no;
if (!D('Order')->where($condition_order)->data($data_order)->save()) {
json_return(1010, '订单信息保存失败');
}
}
import('source.class.Http');
$data = array('pay_money' => $nowOrder['total'], 'trade_no' => $trade_no, 'pay_type' => 'test');
$payment_url = option('config.wap_site_url') . '/paynotice.php';
$result = Http::curlPost($payment_url, $data);
ob_clean();
if (!empty($result['errcode'])) {
json_return(1001, '支付失败');
} else {
json_return(0, option('config.wap_site_url') . '/order.php?orderno=' . option('config.orderid_prefix') . $nowOrder['order_no']);
}
break;
case 'go_pay':
$nowOrder = M('Order')->find($_POST['orderNo']);
if (empty($nowOrder['total'])) {
json_return(1006, '订单异常,请稍后再试');
}
$trade_no = date('YmdHis', $_SERVER['REQUEST_TIME']) . mt_rand(100000, 999999);
if ($nowOrder['status'] > 1) {
json_return(1007, '该订单已支付或关闭<br/>不再允许付款');
示例14: get_access_token
function get_access_token($auth_code)
{
import('source.class.Http');
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
$data = array('component_appid' => option('config.wx_appid'), 'component_appsecret' => option('config.wx_appsecret'), 'component_verify_ticket' => option('config.wx_componentverifyticket'));
$result = Http::curlPost($url, json_encode($data));
if ($result['errcode']) {
return false;
}
//获取 authorizer_appid
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=' . $result['component_access_token'];
//
$data = array('component_appid' => option('config.wx_appid'), 'authorization_code' => $auth_code);
$result1 = Http::curlPost($url, json_encode($data));
if ($result1['errcode']) {
return false;
}
return $result1['authorization_info']['authorizer_access_token'];
}
示例15: get_tmp_qrcode
public function get_tmp_qrcode($qrcode_id)
{
$appid = option('config.wechat_appid');
$appsecret = option('config.wechat_appsecret');
if (empty($appid) || empty($appsecret)) {
return array('error_code' => 1, 'msg' => '请联系管理员配置【AppId】【 AppSecret】');
}
import('Http');
$http = new Http();
//微信授权获得access_token
import('WechatApi');
$tokenObj = new WechatApi(array('appid' => $appid, 'appsecret' => $appsecret));
$access_token = $tokenObj->get_access_token();
$qrcode_url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $access_token['access_token'];
$post_data['expire_seconds'] = 604800;
$post_data['action_name'] = 'QR_SCENE';
$post_data['action_info']['scene']['scene_id'] = $qrcode_id;
$json = $http->curlPost($qrcode_url, json_encode($post_data));
if (!$json['errcode']) {
return array('error_code' => 0, 'id' => $qrcode_id, 'ticket' => 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . urlencode($json['ticket']));
} else {
return array('error_code' => 1, 'msg' => '产生二维码发生错误。发生错误:错误代码 ' . $json['errcode'] . ',微信返回错误信息:' . $json['errmsg']);
}
}