本文整理汇总了PHP中HttpRequest::sendPostRequst方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpRequest::sendPostRequst方法的具体用法?PHP HttpRequest::sendPostRequst怎么用?PHP HttpRequest::sendPostRequst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::sendPostRequst方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($token)
{
$app_id = M('Wxuser')->where(array('token' => $token))->getField('fuwuappid');
if ($_GET['auth_code'] == '') {
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$api_url = 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=' . $app_id . '&auth_skip=false&scope=auth_userinfo,auth_contact&redirect_uri=' . urlencode($redirect_uri);
echo '<script>window.location.href=\'' . $api_url . '\'</script>';
} else {
$auth_code = $_GET['auth_code'];
$fuwuurl = 'https://openapi.alipay.com/gateway.do';
$fuwudata = array('app_id' => $app_id, 'method' => 'alipay.system.oauth.token', 'charset' => 'UTF-8', 'sign_type' => 'RSA', 'timestamp' => date('Y-m-d H:i:s', time()), 'version' => '1.0', 'grant_type' => 'authorization_code', 'code' => $auth_code);
require './PigCms/Lib/ORG/Fuwu/config.php';
$AlipaySign = new AlipaySign();
ksort($fuwudata);
$params = array();
foreach ($fuwudata as $key => $value) {
$params[] = $key . '=' . $value;
}
$fuwudata_build = implode('&', $params);
$fuwudata['sign'] = $AlipaySign->rsa_sign($fuwudata_build, $config['merchant_private_key_file']);
$re = new HttpRequest();
$fuwu_result = $re->sendPostRequst($fuwuurl, $fuwudata);
$return = json_decode(iconv('GBK', 'UTF-8', $fuwu_result), true);
if ($return['alipay_system_oauth_token_response']['access_token'] != '') {
$auth_token = $return['alipay_system_oauth_token_response']['access_token'];
$userinfo_url = 'https://openapi.alipay.com/gateway.do';
$userinfo_data = array('app_id' => $app_id, 'method' => 'alipay.user.userinfo.share', 'charset' => 'GBK', 'sign_type' => 'RSA', 'timestamp' => date('Y-m-d H:i:s', time()), 'version' => '1.0', 'auth_token' => $auth_token);
ksort($userinfo_data);
$params2 = array();
foreach ($userinfo_data as $key2 => $value2) {
$params2[] = $key2 . '=' . $value2;
}
$userinfo_data_build = implode('&', $params2);
$userinfo_data['sign'] = $AlipaySign->rsa_sign($userinfo_data_build, $config['merchant_private_key_file']);
$userinfo_result = $re->sendPostRequst($userinfo_url, $userinfo_data);
$userinfo_return = json_decode(iconv('GBK', 'UTF-8', $userinfo_result), true);
if ($userinfo_return['alipay_user_userinfo_share_response']['user_id'] != '') {
$m_fuwuuser = M('fuwuuser');
$where_fuwuuser['wecha_id'] = 'z_' . md5($userinfo_return['alipay_user_userinfo_share_response']['user_id']);
$where_fuwuuser['token'] = $token;
$fuwuuser = $m_fuwuuser->where($where_fuwuuser)->find();
if ($fuwuuser == '') {
$add_fuwuuser = $userinfo_return['alipay_user_userinfo_share_response'];
$add_fuwuuser['wecha_id'] = 'z_' . md5($userinfo_return['alipay_user_userinfo_share_response']['user_id']);
$add_fuwuuser['token'] = $token;
$add_fuwuuser['addtime'] = time();
$id_fuwuuser = $m_fuwuuser->add($add_fuwuuser);
} else {
$save_fuwuuser = $userinfo_return['alipay_user_userinfo_share_response'];
$update_fuwuuser = $m_fuwuuser->where($where_fuwuuser)->save($save_fuwuuser);
}
$wecha_id = 'z_' . md5($userinfo_return['alipay_user_userinfo_share_response']['user_id']);
return $wecha_id;
}
}
}
}
示例2: apiData
public function apiData($method, $biz_content)
{
$url = 'https://openapi.alipay.com/gateway.do';
$data = array('app_id' => $this->appid, 'method' => $method, 'charset' => 'UTF-8', 'sign_type' => 'RSA', 'timestamp' => date('Y-m-d H:i:s', time()), 'biz_content' => $biz_content, 'version' => '1.0');
require './weimicms/Lib/ORG/Fuwu/config.php';
$AlipaySign = new AlipaySign();
$data['sign'] = $AlipaySign->rsa_sign($this->buildQuery($data), $config['merchant_private_key_file']);
$re = new HttpRequest();
$result = $re->sendPostRequst($url, $data);
return json_decode(iconv('GBK', 'UTF-8', $result), true);
}
示例3: fuwu_code
public function fuwu_code()
{
require './PigCms/Lib/ORG/Fuwu/HttpRequst.php';
require './PigCms/Lib/ORG/Fuwu/aop/AopClient.php';
require './PigCms/Lib/ORG/Fuwu/AlipaySign.php';
$sceneId = (int) $_GET['id'];
$biz_content = '{"codeInfo": {"scene": {"sceneId": "' . $sceneId . '"}},"codeType": "PERM","expireSecond": "","showLogo": "N"}';
$app_id = M("Wxuser")->where(array('token' => $this->token))->getField('fuwuappid');
$url = 'https://openapi.alipay.com/gateway.do';
$data = array('app_id' => $app_id, 'method' => 'alipay.mobile.public.qrcode.create', 'charset' => 'UTF-8', 'sign_type' => 'RSA', 'timestamp' => date('Y-m-d H:i:s', time()), 'biz_content' => $biz_content, 'version' => '1.0');
require './PigCms/Lib/ORG/Fuwu/config.php';
$AlipaySign = new AlipaySign();
$data['sign'] = $AlipaySign->rsa_sign($this->buildQuery($data), $config['merchant_private_key_file']);
$re = new HttpRequest();
$result = $re->sendPostRequst($url, $data);
$return = json_decode(iconv('GBK', 'UTF-8', $result), true);
if ($return['alipay_mobile_public_qrcode_create_response']['code'] == 200) {
$GetDb = M('Recognition');
$where_GetDb['id'] = $sceneId;
$save_GetDb['fuwu_code_url'] = $return['alipay_mobile_public_qrcode_create_response']['code_img'];
$update_GetDb = $GetDb->where($where_GetDb)->save($save_GetDb);
if ($update_GetDb != false) {
$this->success('获取成功');
} else {
$this->error('操作失败');
}
}
}
示例4: sendMsgRequest
/**
* 异步发送消息给用户
*
* @param string $biz_content
* @param string $isMultiSend
* 如果发给所有人,则此参数必须为true,且biz_content中的toUserId必须为空
* @return string
*/
public function sendMsgRequest($biz_content, $isMultiSend = FALSE) {
require FUWU_PATH.'config.php';
$paramsArray = array (
'method' => "alipay.mobile.public.message.custom.send",
'biz_content' => $biz_content,
'charset' => $config ['charset'],
'sign_type' => 'RSA',
'app_id' => FUWU_APPID,
'timestamp' => date ( 'Y-m-d H:i:s', time () )
);
if ($isMultiSend) {
$paramsArray ['method'] = "alipay.mobile.public.message.total.send";
}
require_once FUWU_PATH.'AlipaySign.php';
$as = new AlipaySign ();
$sign = $as->sign_request ( $paramsArray, $config ['merchant_private_key_file'] );
$paramsArray ['sign'] = $sign;
// print_r ( $paramsArray );
// 日志记录下受到的请求
file_put_contents ( "log.txt", var_export ( $paramsArray, true ) . "\r\n", FILE_APPEND );
return HttpRequest::sendPostRequst ( $config ['gatewayUrl'], $paramsArray );
}
示例5: menuQuery
public function menuQuery()
{
global $_GP;
require_once WEB_ROOT . '/includes/lib/alipaySDK/config.php';
require_once WEB_ROOT . '/includes/lib/alipaySDK/HttpRequst.php';
require_once WEB_ROOT . '/includes/lib/alipaySDK/AopSdk.php';
$menus_get = new AlipayMobilePublicMenuGetRequest();
$parDatas = $this->bulidMenuPostData($menus_get->getApiMethodName());
$content = HttpRequest::sendPostRequst($_GP['alipay_config']['gatewayUrl'], $parDatas);
$datas = @json_decode(mb_convert_encoding($content, "UTF-8", "GBK"), true);
$menu_content = $datas['alipay_mobile_public_menu_get_response']["menu_content"];
$menusArr = @json_decode($menu_content, true);
if (is_array($menusArr)) {
$menus = array();
foreach ($menusArr['button'] as $val) {
$m = array();
$m['type'] = $val['actionType'] == 'link' ? 'url' : 'click';
$m['title'] = $val['name'];
if ($m['type'] == 'click') {
$m['forward'] = $val['actionParam'];
} else {
$m['url'] = $val['actionParam'];
}
$m['subMenus'] = array();
if (!empty($val['subButton'])) {
foreach ($val['subButton'] as $v) {
$s = array();
$s['type'] = $v['actionType'] == 'link' ? 'url' : 'click';
$s['title'] = $v['name'];
if ($s['type'] == 'click') {
$s['forward'] = $v['actionParam'];
} else {
$s['url'] = $v['actionParam'];
}
$m['subMenus'][] = $s;
}
}
$menus[] = $m;
}
return $menus;
}
}
示例6: fuwu_code
public function fuwu_code()
{
if (intval($this->wxuser["winxintype"]) != 3 && $this->wxuser["fuwuappid"] == "") {
$this->error($isgostr);
exit;
}
require "./weimicms/Lib/ORG/Fuwu/HttpRequst.php";
require "./weimicms/Lib/ORG/Fuwu/aop/AopClient.php";
require "./weimicms/Lib/ORG/Fuwu/AlipaySign.php";
$sceneId = (int) $_GET["id"];
$biz_content = "{\"codeInfo\": {\"scene\": {\"sceneId\": \"" . $sceneId . "\"}},\"codeType\": \"PERM\",\"expireSecond\": \"\",\"showLogo\": \"N\"}";
$app_id = M("Wxuser")->where(array("token" => $this->token))->getField("fuwuappid");
$url = "https://openapi.alipay.com/gateway.do";
$data = array("app_id" => $app_id, "method" => "alipay.mobile.public.qrcode.create", "charset" => "UTF-8", "sign_type" => "RSA", "timestamp" => date("Y-m-d H:i:s", time()), "biz_content" => $biz_content, "version" => "1.0");
require "./weimicms/Lib/ORG/Fuwu/config.php";
$AlipaySign = new AlipaySign();
$data["sign"] = $AlipaySign->rsa_sign($this->buildQuery($data), $config["merchant_private_key_file"]);
$re = new HttpRequest();
$result = $re->sendPostRequst($url, $data);
$return = json_decode(iconv("GBK", "UTF-8", $result), true);
if ($return["alipay_mobile_public_qrcode_create_response"]["code"] == 200) {
$GetDb = M("Recognition");
$where_GetDb["id"] = $sceneId;
$save_GetDb["fuwu_code_url"] = $return["alipay_mobile_public_qrcode_create_response"]["code_img"];
$update_GetDb = $GetDb->where($where_GetDb)->save($save_GetDb);
if ($update_GetDb != false) {
$this->success("获取成功");
} else {
$this->error("操作失败");
}
} else {
$this->error("appid不正确");
}
}