本文整理汇总了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;
}