本文整理汇总了PHP中HttpClient::post方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::post方法的具体用法?PHP HttpClient::post怎么用?PHP HttpClient::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: core_call
public function core_call($serialized_request)
{
$client = new HttpClient($this->domain);
$client->setCookies($this->cookies);
$client->post($this->location . "json/", $serialized_request);
return $client->getContent();
}
示例2: beacon_send_message
function beacon_send_message($channel, $data)
{
$url = '/1.0.0/' . get_option('beacon_api_key') . '/channels/' . $channel;
$client = new HttpClient('api.beaconpush.com');
$client->extra_request_headers = array('X-Beacon-Secret-Key: ' . get_option('beacon_secret_key'));
$client->post($url, json_encode($data));
}
示例3: verify
/**
* Verifies a recaptcha
*
* @param $priv_key private recaptcha key
* @return true on success
*/
public function verify()
{
$error = ErrorHandler::getInstance();
$conf = RecaptchaConfig::getInstance();
if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) {
$error->add('No captcha answer given.');
return false;
}
if (!$conf->getPublicKey() || !$conf->getPrivateKey()) {
die('ERROR - Get Recaptcha API key at http://recaptcha.net/api/getkey');
}
$params = array('privatekey' => $conf->getPrivateKey(), 'remoteip' => client_ip(), 'challenge' => $_POST['recaptcha_challenge_field'], 'response' => $_POST['recaptcha_response_field']);
$http = new HttpClient($this->api_url_verify);
$res = $http->post($params);
$answers = explode("\n", $res);
if (trim($answers[0]) == 'true') {
return true;
}
switch ($answers[1]) {
case 'incorrect-captcha-sol':
$e = 'Incorrect captcha solution';
break;
default:
$e = 'untranslated error: ' . $answers[1];
}
$error->add($e);
return false;
}
示例4: send
/**
* to config content data and send to target
* @param array $data - content data in array
* (format like array(
* "first"=>array("value"=>"","color"=>""),
* "remark"=>array("value"=>"","color"=>""))
* )
* @return data received after posting
*/
public function send($data)
{
$this->body['data'] = $data;
$json = json_encode($this->body);
$client = new HttpClient("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$this->access_token}");
$client->setParameter($json);
return $client->post();
}
示例5: testJsonPost
function testJsonPost()
{
$http = new HttpClient('http://localhost/coredev_testserver/post_json.php');
$http->setContentType('application/json');
$http->setDebug(true);
$res = $http->post(array('str' => 'abc 123'));
$this->assertEquals($res, 'str=abc+123');
}
示例6: send
public function send($content)
{
$data = array("touser" => $this->openid, "msgtype" => "text", "text" => array("content" => urlencode($content)));
$data = urldecode(json_encode($data));
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$this->access_token}";
$client = new HttpClient($url);
$client->setParameter($data);
return $client->post();
}
示例7: sendMessage
function sendMessage($msgInfo)
{
$client = new HttpClient(FEYIN_HOST, FEYIN_PORT);
if (!$client->post('/api/sendMsg', $msgInfo)) {
//提交失败
return 'faild';
} else {
return $client->getContent();
}
}
示例8: sendSms
public static final function sendSms($path, $apikey, $encoded_text, $mobile, $tpl_id = '', $encoded_tpl_value = '')
{
$client = new HttpClient(self::HOST);
$client->setDebug(false);
if (!$client->post($path, array('apikey' => $apikey, 'text' => $encoded_text, 'mobile' => $mobile, 'tpl_id' => $tpl_id, 'tpl_value' => $encoded_tpl_value))) {
return '-10000';
} else {
return self::__replyResult($client->getContent());
}
}
示例9: apiPost
function apiPost($baseData, $url, $parameters, $private)
{
$nonce = substr(md5(microtime()), 0, 6);
$url = $baseData["path"] . $url;
$msg = "{$url}:{$nonce}:{$private}";
$hash = $nonce . ":" . hash_hmac("sha256", $msg, $parameters["auth_token"]);
$client = new HttpClient($baseData["host"]);
$parameters["auth_hash"] = $hash;
$client->post($url, $parameters);
return $client;
}
示例10: sendRequest
/**
* @param RequestAbstract $request
* @param string $endpointUrl
* @return \Guzzle\Http\EntityBodyInterface|string
* @throws Exception\ConnectionError
*/
private function sendRequest(RequestAbstract $request, $endpointUrl)
{
$client = new HttpClient();
$client->setConfig(array('curl.options' => array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false)));
$httpRequest = $client->post($endpointUrl, null, $request->getRawData());
try {
return $httpRequest->send()->getBody();
} catch (RequestException $e) {
throw new ConnectionError($e->getMessage());
}
}
示例11: sendSms
public static final function sendSms($user, $password, $content, $mobiles)
{
$client = new HttpClient(self::HOST);
$client->setDebug(false);
date_default_timezone_set('PRC');
if (!$client->post('/sdk/send', array('accName' => $user, 'accPwd' => strtoupper($password), 'bizId' => date('YmdHis'), 'content' => mb_convert_encoding($content, 'UTF-8', 'UTF-8'), 'aimcodes' => $mobiles, 'dataType' => "xml"))) {
return '-10000';
} else {
return self::__replyResult($client->getContent());
}
}
示例12: get
/**
* to get the short url by transforming
* @param string $url - long url
* @return string - short url (or boolean false if fail)
*/
public function get($url)
{
if ($this->access_token) {
$client = new HttpClient("https://api.weixin.qq.com/cgi-bin/shorturl?access_token={$this->access_token}");
$client->setParameter(array('action' => 'long2short', 'long_url' => $url));
$stream = json_decode($client->post());
if (isset($stream->short_url)) {
return $stream->short_url;
}
}
return false;
}
示例13: queryOrderNumbersByTime
public function queryOrderNumbersByTime($device_no, $date)
{
$msgInfo = array('clientCode' => $device_no, 'date' => $date);
$client = new HttpClient(FEIE_HOST, FEIE_PORT);
if (!$client->post('/FeieServer/queryorderinfo', $msgInfo)) {
//提交失败
return 'faild';
} else {
$result = $client->getContent();
return $result;
}
}
示例14: wordpress_remote_auth
function wordpress_remote_auth($host, $uri, $login, $pass, $formId = "")
{
$client = new HttpClient($host);
$client->setHandleRedirects(false);
$client->setHeadersOnly(true);
$res = $client->post($uri . "/wp-login.php", array("log" => $login, "pwd" => $pass, "wp-submit" => "Log In", "testcookie" => 1));
$newCookies = extractResponseCookies($client);
if (isset($newCookies["AjaXplorer"])) {
return $newCookies["AjaXplorer"];
}
return "";
}
示例15: create
public function create($statement)
{
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$this->access_token}";
if (is_array($statement)) {
include dirname(__FILE__) . '/../util/arr_urlencode.php';
$statement = arr_urlencode($statement);
$statement = urldecode(json_encode($statement));
}
$client = new HttpClient($url);
$client->setParameter($statement);
return $client->post();
}