setBasicAuthentication() 공개 메소드

Set Basic Authentication
public setBasicAuthentication ( $username, $password = '' )
$username
$password
 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
0
 /**
  * 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
0
<?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
0
<?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";
}