本文整理汇总了PHP中Curl\Curl::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::post方法的具体用法?PHP Curl::post怎么用?PHP Curl::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl\Curl
的用法示例。
在下文中一共展示了Curl::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* @author mohuishou<1@lailin.xyz>
* @return $this
* @throws \Exception
*/
protected function login()
{
//判断是否已经登录
if (!empty($this->_login_cookie)) {
return $this;
}
//设置header伪造来源以及ip
$ip = rand(1, 233) . '.' . rand(1, 233) . '.' . rand(1, 233) . '.' . rand(1, 233);
$this->_curl->setHeader("X-Forwarded-For", $ip);
$this->_curl->setHeader("Referer", 'http://202.115.47.141/login.jsp');
$param = ["zjh" => $this->_uid, "mm" => $this->_password];
$this->_curl->post('http://202.115.47.141/loginAction.do', $param);
if ($this->_curl->error) {
throw new \Exception('Error: ' . $this->_curl->errorCode . ': ' . $this->_curl->errorMessage, 5001);
}
//判断是否登录成功
$page = $this->_curl->response;
$page = iconv('GBK', 'UTF-8//IGNORE', $page);
$rule = ['err' => ['.errorTop', 'text']];
$err = QueryList::Query($page, $rule)->data;
if (!empty($err)) {
throw new \Exception('Error:' . $err[0]['err'], 4011);
}
//登录成功之后设置cookie
$this->_login_cookie = $this->_curl->getResponseCookie("JSESSIONID");
$this->_curl->setCookie('JSESSIONID', $this->_login_cookie);
return $this;
}
示例2: sendSparqlSelectQuery
/**
*
* @param string $query
* @return
* @throw
*/
public function sendSparqlSelectQuery($query)
{
// TODO extend Accept headers to further formats
$this->client->setHeader("Accept", "application/sparql-results+json");
$this->client->setHeader("Content-Type", "application/x-www-form-urlencoded");
return $this->client->post($this->url, array("query" => $query));
}
示例3: scrapeWithYQL
/**
* @param $yql_query
* @param string $format ('xml', 'json')
* @return bool|string
*/
public function scrapeWithYQL($yql_query, $format = '')
{
$this->initCurl();
$encoded_yql_query = rawurldecode($yql_query);
$encoded_yql_query = str_replace("%2A", "*", $encoded_yql_query);
$this->curl->post(self::YAHOO_CONSOLE_URL, array('q' => $encoded_yql_query, 'format' => $format));
return $this->handleCurlResponse();
}
示例4: initLogin
private function initLogin($login)
{
if ($login != null) {
$lf = new LoginForm();
$lf->setEntity($login);
$data = $lf->getPostData();
$url = $lf->getURL();
$this->curl->get($url);
$this->curl->post($url, $data);
} else {
throw new Exception('Login cannot be null!');
}
}
示例5: callMethod
/**
* Call method and get answer
*
* @param string $method Method name
* @param array $args Method arguments
*
* @return Answer
* @throws AnswerException
*/
public function callMethod($method, array $args = [])
{
ArgValidator::assert($method, ['string', 'notEmpty']);
$xml = $this->prepareXmlForRequest($method, $args);
$result = $this->curl->post($this->apiUrl, ['xml' => base64_encode($xml)]);
return $this->parseAnswer($result);
}
示例6: getData
/**
* docomoの対話APIを叩いてレスポンスを貰ってくる
*
* @param string $apikey docomoAPIキー
* @param string $context 会話のコンテキストID(API仕様参照)
* @param string $mode 会話のモード(API仕様参照
* @param string $nickname 会話している人間側の名前
* @param string $text 人間側の入力テキスト
* @return stdClass レスポンスのJSONをデコードしたオブジェクト
* @throws \Exception サーバとの通信に失敗した場合
*/
private function getData($apikey, $context, $mode, $nickname, $text)
{
$userData = ['utt' => (string) $text, 'context' => (string) $context, 'nickname' => (string) $nickname, 'mode' => (string) $mode];
$url = sprintf('https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=%s', rawurlencode($apikey));
Log::info("docomo対話APIを呼び出します");
Log::info("URL: " . $url);
Log::info("パラメータ:");
Log::info($userData);
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json; charset=UTF-8');
$ret = $curl->post($url, json_encode($userData));
if ($curl->error) {
Log::error(sprintf("docomo対話APIの呼び出しに失敗しました: %d: %s", $curl->error_code, $curl->error_message));
throw new \Exception('docomo dialogue error: ' . $curl->error_code . ': ' . $curl->error_message);
}
Log::info("docomoからのデータ:");
Log::info($ret);
if (is_object($ret) && isset($ret->utt)) {
if ($ret->utt == '') {
Log::warning(" docomo 指示文章が空です");
} else {
Log::success(" docomo 指示文章: " . $ret->utt);
}
return $ret;
}
Log::error("docomoから受け取ったデータが期待した形式ではありません:");
Log::error($ret);
throw new \Exception('Received an unexpected data from docomo server');
}
示例7: createSubAccount
/**
* @param string $apiKey
* @param string $apiSecret
* @param string $subAccountName
*
* @return AccountResponse
*/
public static function createSubAccount($apiKey, $apiSecret, $subAccountName)
{
$apiEndpoint = sprintf('%s/subaccounts', self::API_URL);
$curl = new Curl();
$curl->post($apiEndpoint, json_encode(['api_key' => $apiKey, 'api_secret' => $apiSecret, 'name' => $subAccountName]));
return self::parseResponse($curl);
}
示例8: trigger
static function trigger($channel, $event, $data)
{
WebpushPHP::validate();
$curl = new Curl();
$response = $curl->post(WebpushPHP::$apipath . '/trigger', ['token' => WebpushPHP::$token, 'secret' => WebpushPHP::$secret, 'channel' => $channel, 'event' => $event, 'data' => json_encode($data)]);
return $response;
}
示例9: update
public function update(SIP $sip)
{
//initialize sip extension core
$se = new SIPExtension();
$se->action = 'edit';
$se->extDisplay = $sip->id;
$se->extension = $sip->extension;
$se->SIPName = $sip->extension;
$se->name = $sip->name;
$dv = new DevInfo();
$dv->secret = $sip->secret;
$se->setDevInfo($dv);
$ad = new AssignDIDAndCID();
$se->setAssignDidAndCid($ad);
//initialize sip extension form executor
$sf = new SIPExtensionForm();
$sf->setEntity($se);
$sf->setLogin($this->login);
//do login to elastic
$this->initLogin();
//execution for update sip extension
$d1 = $sf->getSIPData();
$u1 = $sf->getUpdateURL();
$this->curl->post($u1, $d1);
}
示例10: http_request
public function http_request($data_fields)
{
$curl = new Curl();
$curl->setHeader('Phant-Private-Key', $this->private_key);
$curl->post($this->server_hostname . '/input/' . $this->public_key, $data_fields);
if ($curl->error)
{
return array(
'response' => trim($curl->response),
'http_status' => $curl->response_headers['Status-Line'],
'X-Rate-Limit-Limit' => $curl->response_headers['X-Rate-Limit-Limit'],
'X-Rate-Limit-Remaining' => $curl->response_headers['X-Rate-Limit-Remaining'],
'X-Rate-Limit-Reset' => $curl->response_headers['X-Rate-Limit-Reset'],
);
}
else
{
return array(
'response' => trim($curl->response),
'http_status' => $curl->response_headers['Status-Line'],
'X-Rate-Limit-Limit' => $curl->response_headers['X-Rate-Limit-Limit'],
'X-Rate-Limit-Remaining' => $curl->response_headers['X-Rate-Limit-Remaining'],
'X-Rate-Limit-Reset' => $curl->response_headers['X-Rate-Limit-Reset'],
);
}
}
示例11: view_day
public function view_day($year, $month, $view_day)
{
$dateFormat = array("date" => $year . "/" . $month . "/" . $view_day);
$curl = new Curl();
$curl->post(API . "history/date", $dateFormat);
// die("<pre>".print_r($curl->response, true));
return $curl->response;
}
示例12: fromFile
/**
* @param KrakenOptions $options
* @param KrakenImage $image
*
* @return CompressResponse
*/
public static function fromFile(KrakenOptions $options, KrakenImage $image)
{
$apiEndpoint = sprintf('%s/upload', self::API_URL);
$file = class_exists('CURLFile') ? new \CURLFile($image->getPath()) : sprintf('@%s', $image->getPath());
$curl = new Curl();
$curl->post($apiEndpoint, ['file' => $file, 'data' => json_encode($options->getConfiguredOptions())]);
return self::parseResponse($curl);
}
示例13: doRequest
public function doRequest($endpoint, $version = null)
{
$data = $this->getData();
$uri = Config::getApiUrl($endpoint, $version);
$curl = new Curl();
$result = $curl->post($uri, $data);
$output = self::processResult($result);
return $output;
}
示例14: renderException
public function renderException($exception)
{
if ($exception instanceof NotFoundHttpException || !$this->transferException) {
return parent::renderException($exception);
}
$curl = new Curl();
$response = $curl->post(rtrim($this->api, '/') . '/create', ['error_json' => Json::encode($this->getExceptionArray($exception))]);
return parent::renderException($exception);
}
示例15: apiServerSendData
/**
* Send the array data to the api server.
*
* @param array $data The array to be sent to the server.
* @return boolean|null true/false if data has been sent to the api successfull or not, null if the transfer is disabled.
*/
private function apiServerSendData(array $data)
{
if ($this->transferException) {
$curl = new Curl();
$curl->post(Url::ensureHttp(rtrim($this->api, '/')) . '/create', ['error_json' => Json::encode($data)]);
return !$curl->error;
}
return null;
}