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


PHP Curl::setBasicAuthentication方法代码示例

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


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

示例1: connect

 private function connect()
 {
     $curl = new Curl();
     $curl->setBasicAuthentication($this->adminUsername, $this->adminPassword);
     $curl->setUserAgent('');
     $curl->setReferrer('');
     $curl->setHeader('X-Requested-With', 'XMLHttpRequest');
     $this->curl = $curl;
 }
开发者ID:dbugit,项目名称:owncloud-php-interface,代码行数:9,代码来源:owncloudPHPInterface.php

示例2: setAuthMethod

 /**
  * Set auth method for curl request
  *
  * @param string "apikey" or "basic"
  */
 private function setAuthMethod($authMethod)
 {
     switch ($authMethod) {
         case 'apikey':
             $this->curl->setHeader('X-API-KEY', $this->apiKey);
             break;
         case 'basic':
         default:
             $this->curl->setBasicAuthentication($this->apiUsername, $this->apiPassword);
             break;
     }
 }
开发者ID:raket,项目名称:Shopello-PHP,代码行数:17,代码来源:Api3Client.php

示例3: array

<?php

require '../src/Curl/Curl.php';
use Curl\Curl;
define('GRATIPAY_USERNAME', 'XXXXXXXXXX');
define('GRATIPAY_API_KEY', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
$data = array(array('username' => 'user' . mt_rand(), 'platform' => 'gratipay', 'amount' => '0.02'), array('username' => 'user' . mt_rand(), 'platform' => 'gratipay', 'amount' => '0.02'));
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setBasicAuthentication(GRATIPAY_API_KEY);
$curl->post('https://gratipay.com/' . GRATIPAY_USERNAME . '/tips.json', json_encode($data));
foreach ($curl->response as $tip) {
    echo $tip->amount . ' given to ' . $tip->username . '.' . "\n";
}
开发者ID:linxon,项目名称:php-curl-class,代码行数:14,代码来源:gratipay_send_tip.php

示例4: array

<?php

require '../src/Curl/Curl.php';
use Curl\Curl;
define('GITTIP_USERNAME', 'XXXXXXXXXX');
define('GITTIP_API_KEY', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
$data = array(array('username' => 'user' . mt_rand(), 'platform' => 'gittip', 'amount' => '0.02'), array('username' => 'user' . mt_rand(), 'platform' => 'gittip', 'amount' => '0.02'));
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setBasicAuthentication(GITTIP_API_KEY);
$curl->post('https://www.gittip.com/' . GITTIP_USERNAME . '/tips.json', json_encode($data));
foreach ($curl->response as $tip) {
    echo $tip->amount . ' given to ' . $tip->username . '.' . "\n";
}
开发者ID:craa,项目名称:php-curl-class,代码行数:14,代码来源:gittip_send_tip.php


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