本文整理汇总了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;
}
示例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;
}
}
示例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";
}
示例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";
}