本文整理汇总了PHP中HttpClient::setParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::setParameter方法的具体用法?PHP HttpClient::setParameter怎么用?PHP HttpClient::setParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::setParameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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;
}