当前位置: 首页>>代码示例>>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;未经允许,请勿转载。