示例#1
0
 public function __construct($consumerKey, $consumerSecret, $signatureMethod = 'HMAC-SHA1')
 {
     $this->consumerKey = $consumerKey;
     $this->consumerSecret = $consumerSecret;
     $this->signatureMethod = $signatureMethod;
     $this->curl = EpiCurl::getInstance();
 }
示例#2
0
 private function request_basic($method, $endpoint, $params = null, $username = null, $password = null)
 {
     $url = $this->getApiUrl($endpoint);
     if ($method === 'GET') {
         $url .= is_null($params) ? '' : '?' . http_build_query($params, '', '&');
     }
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
     if ($method === 'POST' && $params !== null) {
         if ($this->isMultipart($params)) {
             curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
         } else {
             curl_setopt($ch, CURLOPT_POSTFIELDS, $this->buildHttpQueryRaw($params));
         }
     }
     if (!empty($username) && !empty($password)) {
         curl_setopt($ch, CURLOPT_USERPWD, "{$username}:{$password}");
     }
     $resp = new EpiTwitterJson(EpiCurl::getInstance()->addCurl($ch), $this->debug);
     if (!$this->isAsynchronous) {
         $resp->response;
     }
     return $resp;
 }
示例#3
0
<?php

use jmathai\php_multi_curl\EpiCurl;
include './EpiCurl.php';
$mc = EpiCurl::getInstance();
$yahoo = $mc->addURL('http://www.yahoo.com');
// call yahoo
$google = $mc->addURL('http://www.google.com');
// call google
$ebay = $mc->addURL('http://www.ebay.com');
// call ebay
// fetch response from yahoo and google
echo "The response code from Yahoo! was {$yahoo->code}\n";
echo "The response code from Google was {$google->code}\n";
$microsoft = $mc->addURL('http://www.microsoft.com');
// call microsoft
// fetch response from ebay and microsoft
echo "The response code from Ebay was {$ebay->code}\n";
echo "The response code from Microsoft was {$microsoft->code}\n";
示例#4
0
 function __construct($key)
 {
     $this->key = $key;
     $this->epiCurl = EpiCurl::getInstance();
 }