当前位置: 首页>>代码示例>>PHP>>正文


PHP Curl::put方法代码示例

本文整理汇总了PHP中Curl\Curl::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::put方法的具体用法?PHP Curl::put怎么用?PHP Curl::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Curl\Curl的用法示例。


在下文中一共展示了Curl::put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $fileName = 'main';
     $config = new Configuration($this->getConfigPaths(), $fileName);
     $columnId = $input->getArgument('columnId');
     $taskId = $input->getArgument('taskId');
     $domain = $config->getValue('domain');
     $boardId = $config->getValue('boardId');
     $apiToken = $config->getValue('apiToken');
     $url = $this->getUrl($domain, $boardId, $apiToken, $taskId);
     $curl = new Curl();
     $curl->put($url, array('workflow_stage_id' => $columnId));
 }
开发者ID:oliverlorenz,项目名称:php-kanbantool-cli,代码行数:15,代码来源:TaskMove.php

示例2: put

 public function put($url = false, $params = false)
 {
     if ($url) {
         if ($params === false) {
             $params = array();
         }
         $curl = new Curl();
         $curl->put($url, $params);
         if ($curl->error) {
             return $curl->errorCode . ': ' . $curl->errorMessage;
         } else {
             return $curl->response;
         }
     }
     return false;
 }
开发者ID:prototypemvc,项目名称:prototypemvc,代码行数:16,代码来源:Request.php

示例3: call

 /**
  * Make API-call
  */
 private function call($method, $uri, $getParams = array(), $postParams = array(), $authMethod = 'basic')
 {
     $uri = $this->apiEndpoint . $uri;
     $getParams = array_merge($this->apiGetParams, $getParams);
     // Filter empty params
     $getParams = array_filter($getParams, function ($var) {
         return !empty($var);
     });
     // CURL Stuff
     $this->applyCurlOptions($authMethod);
     // Do Request
     switch ($method) {
         case 'get':
             $this->curl->get($uri, $getParams);
             break;
         case 'post':
             $this->curl->post($uri . '?' . http_build_query($getParams), $postParams);
             break;
         case 'delete':
             $this->curl->delete($uri, $getParams);
             break;
         case 'put':
             $this->curl->put($uri . '?' . http_build_query($getParams), $postParams);
             break;
         default:
             throw new \Exception('Requested method behaviour is not defined yet');
     }
     if ($this->curl->curl_error_code == 28) {
         throw new \Exception('Connection timeout', 28);
     }
     $error = $this->curl->error;
     if ($error) {
         throw new \Exception($error . ' (HTTP CODE ' . $this->curl->http_status_code . ')');
     }
     // If JSONP is activated, return instantly
     if (isset($extraParams['callback'])) {
         return $this->curl->response;
     }
     // Otherwise decode and return
     $result = json_decode($this->curl->response);
     return $result;
 }
开发者ID:raket,项目名称:Shopello-PHP,代码行数:45,代码来源:Api3Client.php

示例4: testSetUrl

 public function testSetUrl()
 {
     $data = array('key' => 'value');
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->delete($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->get($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->head($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('HEAD /?key=value HTTP/1.1', $curl->request_headers['Request-Line']);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->options($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'request_method');
     $curl->setUrl(Test::TEST_URL);
     $curl->patch($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('PATCH', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'post');
     $curl->setUrl(Test::TEST_URL);
     $curl->post($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'put');
     $curl->setUrl(Test::TEST_URL);
     $curl->put($data);
     $this->assertEquals(Test::TEST_URL, $curl->base_url);
     $this->assertEquals('key=value', $curl->response);
 }
开发者ID:aguillem,项目名称:festival-manager,代码行数:46,代码来源:PHPCurlClassTest.php

示例5: Curl

<?php

require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;
// curl -X PUT -d "id=1&first_name=Zach&last_name=Borboa" "https://httpbin.org/put"
$curl = new Curl();
$curl->put('https://httpbin.org/put', array('id' => 1, 'first_name' => 'Zach', 'last_name' => 'Borboa'));
echo 'Data server received via PUT:' . "\n";
var_dump($curl->response->form);
开发者ID:ice-wolf,项目名称:polyglotcode,代码行数:9,代码来源:put.php

示例6: Exception

const CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXX';
const REDIRECT_URI = 'https://www.example.com/oauth2callback';
if (php_sapi_name() !== 'cli') {
    throw new Exception('This application must be run on the command line.');
}
// Request authorization from the user.
$auth_url = OAUTH2_AUTH_URL . '?' . http_build_query(array('access_type' => 'offline', 'approval_prompt' => 'force', 'client_id' => CLIENT_ID, 'redirect_uri' => REDIRECT_URI, 'response_type' => 'code', 'scope' => 'https://www.googleapis.com/auth/spreadsheets'));
echo 'Open the following link in your browser:' . "\n";
echo $auth_url . "\n";
echo 'Enter verification code: ';
$code = trim(fgets(STDIN));
// Exchange authorization code for an access token.
$curl = new Curl();
$curl->post(OAUTH2_TOKEN_URI, array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'code' => $code, 'grant_type' => 'authorization_code', 'redirect_uri' => REDIRECT_URI));
$access_token = $curl->response;
// Update spreadsheet.
$spreadsheet_id = '1Z2cXhdG-K44KgSzHTcGhx1dY-xY31yuYGwX21F4GeUp';
$range = 'Sheet1!A1';
$url = 'https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheet_id . '/values/' . $range;
$url .= '?' . http_build_query(array('valueInputOption' => 'USER_ENTERED'));
$data = array('values' => array(array('This is cell A1', 'B1', 'C1', 'and D1')));
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setHeader('Authorization', 'Bearer ' . $access_token->access_token);
$curl->put($url, $data);
if ($curl->error) {
    echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
    var_dump($curl);
} else {
    var_dump($curl->response);
}
开发者ID:php-curl-class,项目名称:php-curl-class,代码行数:31,代码来源:google_spreadsheet_values_update.php

示例7: testSetUrl

 public function testSetUrl()
 {
     $data = array('key' => 'value');
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->delete($data);
     $this->assertEquals('DELETE /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->get($data);
     $this->assertEquals('GET /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->head($data);
     $this->assertEquals('HEAD /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->options($data);
     $this->assertEquals('OPTIONS /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->patch($data);
     $this->assertEquals('PATCH / HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->post($data);
     $this->assertEquals('POST / HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
     $curl = new Curl();
     $curl->setUrl(Test::TEST_URL);
     $curl->put($data);
     $this->assertEquals('PUT / HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
 }
开发者ID:php-curl-class,项目名称:php-curl-class,代码行数:39,代码来源:PHPCurlClassTest.php

示例8: read_file

<?php

// PUT a file using chunked data.
// See also "examples/receive_large_file_chunked.php".
require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;
function read_file($ch, $fd, $length)
{
    $data = fread($fd, $length);
    return $data;
}
$filename = 'large_image.png';
$fp = fopen($filename, 'rb');
$curl = new Curl();
$curl->setHeader('Transfer-Encoding', 'chunked');
$curl->setOpt(CURLOPT_UPLOAD, true);
$curl->setOpt(CURLOPT_INFILE, $fp);
$curl->setOpt(CURLOPT_INFILESIZE, filesize($filename));
$curl->setOpt(CURLOPT_READFUNCTION, 'read_file');
$curl->put('http://127.0.0.1:8000/');
fclose($fp);
if ($curl->error) {
    echo 'Error: ' . $curl->errorMessage . "\n";
} else {
    echo 'Success' . "\n";
}
开发者ID:zachborboa,项目名称:php-curl-class,代码行数:26,代码来源:put_large_file_chunked.php


注:本文中的Curl\Curl::put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。