public function __call($method, $args) { $method = explode('_', $method); $method = array_reverse($method); $method = implode('/', $method); $data = $args[0]; $url = 'https://api.weixin.qq.com/cgi-bin/' . $method . '?access_token=' . $this->access_token; $param = json_encode($data, JSON_UNESCAPED_UNICODE); $ret_json = CURL::post($url, $param); $ret_array = json_decode($ret_json, true); return $ret_array; }
public static function transfers($params) { $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; $params['mchid'] = self::$config['mch_id']; //微信支付分配的商户号 1900000109 $params['mch_appid'] = self::$config['wxappid']; //微信分配的公众账号ID(企业号corpid即为此appId) wx8888888888888888 $params['spbill_create_ip'] = self::get_client_ip(); //调用接口的机器Ip地址 $params['check_name'] = 'NO_CHECK'; $params['nonce_str'] = self::random(16); $params['sign'] = self::sign($params); $opts = array(CURLOPT_SSLCERT => 'apiclient_cert.pem', CURLOPT_SSLKEY => 'apiclient_key.pem', CURLOPT_CAINFO => 'rootca.pem'); $params_xml = self::array2xml($params); $ret_xml = CURL::post($url, $params_xml, $opts); $ret_array = self::xml2array($ret_xml); return $ret_array; }
public function push_bstock_order() { global $dbConn; //$id = $_POST['combine_id']; $id = $_POST['idArr']; //$idArr = $_POST['idArr']; //$idStr = implode(",",$idArr); $sql = " SELECT * FROM `ph_ow_order` where id={$id} and status=3"; $sql = $dbConn->execute($sql); $item = $dbConn->fetch_one($sql); $url = "http://wh.valsun.cn/openapi.php?jsonp=1&mod=syncPreGoodsOrder&act=syncPreGoodsOrderInfo"; $curl = new CURL(); $ordersn = $item['recordnumber']; $owner = $item['purchaseuser_id']; $createtime = $item['addtime']; $sql = "SELECT * FROM `ph_ow_order_detail` where recordnumber='{$ordersn}'"; $sql = $dbConn->execute($sql); $orderdetail = $dbConn->getResultArray($sql); $data = array(); foreach ($orderdetail as $itemdetail) { $data[$itemdetail['sku']] = $itemdetail['count']; } $postData = array("orderSn" => $ordersn, "owner" => $owner, "createtime" => $createtime, "data" => json_encode($data)); $rtn = $curl->post($url, $postData, false); $rtn = json_decode($rtn, true); if ($rtn['data']['code'] == "success") { $sql = "update ph_ow_order set status=4 where recordnumber='{$ordersn}'"; $dbConn->execute($sql); } return json_encode($rtn); }
/** * Perform a REST "post" method at a URL * * @param String $url the URL to "post" * @param Array $data the data to "post" * @param String $type the content type to use (optional) * @param String $charset the charset encoding to use (optional) * @return Array any decoded data returned from the method */ public static function post($url, $data, $type = NULL, $charset = NULL) { $type = first($type, self::$type); $charset = first($charset, self::$charset); $data = Data::to($type, $data); $text = CURL::post($url, $data, self::headers_for($type)); return self::decode($type, $text, 'post'); }
public function setMenu() { /*{{{*/ $access_token = $this->weixin_access_token_get(); $setMenuUrl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$access_token}"; $menu = ['button' => [['type' => 'view', 'name' => "搞机干货", 'url' => 'http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzIzNjM4NzAzMg==#wechat_webview_type=1&wechat_redirect'], ['type' => 'view', 'name' => "商城", 'url' => 'https://kdt.im/EX31Ur'], ['type' => 'click', 'name' => "用户服务", 'key' => 'user_service']]]; $res = CURL::post($setMenuUrl, json_encode($menu, JSON_UNESCAPED_UNICODE)); var_dump($res); }