本文整理汇总了PHP中Curl::post_request方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::post_request方法的具体用法?PHP Curl::post_request怎么用?PHP Curl::post_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::post_request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: push
/**
* Push the notification.
*
* @return GCMResponse $return Response object
*/
public function push()
{
$this->curl->set_option('CURLOPT_HEADER', TRUE);
$this->curl->set_http_headers(['Content-Type:application/json', 'Authorization: key=' . $this->auth_token]);
$tmp_payload = json_decode($this->payload, TRUE);
$tmp_payload['registration_ids'] = [$this->endpoint];
$tmp_payload['priority'] = $this->priority;
$this->payload = json_encode($tmp_payload);
$response = $this->curl->post_request(self::GOOGLE_SEND_URL, $this->payload);
$res = new GCMResponse($response, $this->logger, $this->endpoint);
$this->endpoint = '';
$this->payload = '';
return $res;
}
示例2: get_json_results
/**
* Fetch and parse results as though they were a query string.
*
* @param String $url API URL
* @param Array $params Array of parameters for the API request
* @param String $method Request method to use, either 'get' or 'post'
*
* @return Array $result Array of return values
*/
protected function get_json_results($url, $params = [], $method = 'get')
{
if (strtolower($method) === 'get') {
$response = $this->curl->get_request($url . '?' . http_build_query($params));
} else {
$response = $this->curl->post_request($url, $params);
}
$result = json_decode($response->get_result(), TRUE);
if ($response->http_code !== 200) {
$error = $result['errors'][0];
$context = ['message' => $error['message'], 'code' => $error['code'], 'request' => $url];
$this->logger->error('Twitter API Request ({request}) failed, ({code}): {message}', $context);
$result = '';
}
unset($response);
return $result;
}
示例3: push
/**
* Push the notification.
*
* @return PAPResponse $return Response object
*/
public function push()
{
// construct PAP URL
$pap_url = "https://cp{$this->cid}.pushapi.na.blackberry.com/mss/PD_pushRequest";
$pap_data = $this->construct_pap_data();
$this->curl->set_option('CURLOPT_URL', $pap_url);
$this->curl->set_option('CURLOPT_HEADER', FALSE);
$this->curl->set_option('CURLOPT_HTTP_VERSION', CURL_HTTP_VERSION_1_1);
$this->curl->set_option('CURLOPT_HTTPAUTH', CURLAUTH_BASIC);
$this->curl->set_option('CURLOPT_USERPWD', $this->auth_token . ':' . $this->password);
$this->curl->set_option('CURLOPT_RETURNTRANSFER', TRUE);
$this->curl->set_http_header('Content-Type: multipart/related; boundary=' . self::PAP_BOUNDARY . '; type=application/xml');
$this->curl->set_http_header('Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2');
$this->curl->set_http_header('Connection: keep-alive');
$response = $this->curl->post_request($pap_url, $pap_data);
$res = new PAPResponse($response, $this->logger, $this->endpoint);
$this->endpoint = '';
$this->push_id = '';
$this->payload = '';
$this->deliverbefore = '';
return $res;
}