本文整理匯總了PHP中Curl::httpPost方法的典型用法代碼示例。如果您正苦於以下問題:PHP Curl::httpPost方法的具體用法?PHP Curl::httpPost怎麽用?PHP Curl::httpPost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Curl
的用法示例。
在下文中一共展示了Curl::httpPost方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: text
public function text($content)
{
$token = $this->getAccessToken($this->mpid);
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token['token']}";
$res = Curl::httpPost($url, json_encode(['touser' => $this->openid, 'msgtype' => 'text', 'text' => ['content' => $content]]));
$res = json_decode($res);
if ($res->errcode === 0) {
return true;
} else {
$this->errmsg = $res->errmsg;
return false;
}
}
示例2: callWebServer
/**
* 調用外部url
* @param $queryUrl
* @param $param
* @param string $method
* @return bool|mixed
*/
public static function callWebServer($queryUrl, $param, $method = 'get')
{
if (empty($queryUrl)) {
return false;
}
$method = strtolower($method);
$ret = '';
$param = empty($param) ? array() : $param;
$curlObj = new Curl();
if ($method == 'get') {
$ret = $curlObj->httpGet($queryUrl, GAME_URL, $param);
} elseif ($method == 'post') {
$ret = $curlObj->httpPost($queryUrl, GAME_URL, $param);
}
if (!empty($ret)) {
return json_decode($ret, true);
}
return true;
}
示例3: bulk
public function bulk($str)
{
$result = array('status' => 0, 'data' => '', 'err' => '');
if (!strstr(substr($str, -2), PHP_EOL)) {
$str = $str . "\n";
}
// $res = Curl::httpPost($this->_url.$this->_name.'/',json_encode($params),false,true);
$res = Curl::httpPost($this->_url . '_bulk', $str, false, true);
if ($res['header']['http_code'] == 200) {
$fbody = json_decode($res['body'], true);
$result['status'] = $fbody['errors'] == false ? 1 : 0;
$result['data'] = $res['body'];
} elseif ($res['err'] != '') {
throw new \Exception($res['err']);
} else {
$result['status'] = 0;
$result['data'] = $res['body'];
}
return $result;
}
示例4: open
public function open()
{
$result = array('status' => 0, 'data' => '', 'err' => '');
$res = Curl::httpPost($this->_url . $this->_name . '/_open', array(), false, true);
if ($res['header']['http_code'] == 200) {
$result['status'] = 1;
$result['data'] = $res['body'];
} elseif ($res['err'] != '') {
throw new \Exception($res['err']);
} else {
$result['status'] = 0;
$result['data'] = $res['body'];
}
return $result;
}