當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Curl::post方法代碼示例

本文整理匯總了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;
 }
開發者ID:mohuishou,項目名稱:scuplus-jwc-package,代碼行數:33,代碼來源:JwcBase.php

示例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));
 }
開發者ID:guitarmarx,項目名稱:Saft,代碼行數:13,代碼來源:Client.php

示例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();
 }
開發者ID:gyvastis,項目名稱:yql-web-scraper,代碼行數:13,代碼來源:YQLWebScraper.php

示例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!');
     }
 }
開發者ID:oz4n,項目名稱:elastic-api,代碼行數:13,代碼來源:ParserSIPTrunk.php

示例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);
 }
開發者ID:gennadyx,項目名稱:shop-logistics.ru-api,代碼行數:16,代碼來源:Api.php

示例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');
 }
開發者ID:nonoliri,項目名稱:chomado_bot,代碼行數:40,代碼來源:Chat.php

示例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);
 }
開發者ID:mikeymike,項目名稱:kraken,代碼行數:14,代碼來源:Account.php

示例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;
 }
開發者ID:default-settings,項目名稱:webpush-php,代碼行數:7,代碼來源:WebpushPHP.php

示例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);
 }
開發者ID:oz4n,項目名稱:elastic-api,代碼行數:25,代碼來源:SIPManager.php

示例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'],
			);
		}	
	}
開發者ID:seanmhayes,項目名稱:IERG_FOTF,代碼行數:26,代碼來源:PHPePhant.php

示例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;
 }
開發者ID:oscarsmartwave,項目名稱:l45fbl45t,代碼行數:8,代碼來源:Appointments_model.php

示例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);
 }
開發者ID:mikeymike,項目名稱:kraken,代碼行數:14,代碼來源:Compress.php

示例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;
 }
開發者ID:patrickkivits,項目名稱:sdk,代碼行數:9,代碼來源:Api.php

示例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);
 }
開發者ID:rocksolid-tn,項目名稱:luya,代碼行數:9,代碼來源:ErrorHandler.php

示例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;
 }
開發者ID:luyadev,項目名稱:luya-core,代碼行數:15,代碼來源:ErrorHandlerTrait.php


注:本文中的Curl\Curl::post方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。