コード例 #1
0
 protected static function _create($params = null)
 {
     self::_validateParams($params);
     $url = static::classUrl();
     list($response) = static::_staticRequest('post', $url, $params);
     return Util\Util::convertToDeviceToolObject($response);
 }
コード例 #2
0
 public function testIsList()
 {
     $list = array(5, 'nstaoush', array());
     $this->assertTrue(Util\Util::isList($list));
     $notlist = array(5, 'nstaoush', array(), 'bar' => 'baz');
     $this->assertFalse(Util\Util::isList($notlist));
 }
コード例 #3
0
 /**
  * @return null|string The instance URL for this resource. It needs to be special
  *                     cased because it doesn't fit into the standard resource pattern.
  *
  * @throws Error\InvalidRequest
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     if (!$id) {
         $class = get_class($this);
         $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}";
         throw new Error\InvalidRequest($msg, null);
     }
     if ($this['customer']) {
         $parent = $this['customer'];
         $base = Customer::classUrl();
         $path = 'sources';
     } elseif ($this['account']) {
         $parent = $this['account'];
         $base = Account::classUrl();
         $path = 'external_accounts';
     } elseif ($this['recipient']) {
         $parent = $this['recipient'];
         $base = Recipient::classUrl();
         $path = 'cards';
     } else {
         return;
     }
     $parent = Util\Util::utf8($parent);
     $id = Util\Util::utf8($id);
     $parentExtn = urlencode($parent);
     $extn = urlencode($id);
     return "{$base}/{$parentExtn}/{$path}/{$extn}";
 }
コード例 #4
0
ファイル: Collection.php プロジェクト: Enflick/stripe-php
 public function retrieve($id, $params = null, $opts = null)
 {
     list($url, $params) = $this->extractPathAndUpdateParams($params);
     $id = Util\Util::utf8($id);
     $extn = urlencode($id);
     list($response, $opts) = $this->_request('get', "{$url}/{$extn}", $params, $opts);
     return Util\Util::convertToStripeObject($response, $opts);
 }
コード例 #5
0
ファイル: BalanceTest.php プロジェクト: cso4tb/Auxum-
 public function testRetrieve()
 {
     self::authorizeFromEnv();
     $d = Balance::retrieve();
     $this->assertSame($d->object, "balance");
     $this->assertTrue(Util\Util::isList($d->available));
     $this->assertTrue(Util\Util::isList($d->pending));
 }
コード例 #6
0
ファイル: Invoice.php プロジェクト: cso4tb/Auxum-
 /**
  * @param array|null $params
  * @param array|string|null $opts
  *
  * @return Invoice The upcoming invoice.
  */
 public static function upcoming($params = null, $opts = null)
 {
     $url = static::classUrl() . '/upcoming';
     list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
     $obj = Util\Util::convertToStripeObject($response->json, $opts);
     $obj->setLastResponse($response);
     return $obj;
 }
コード例 #7
0
 /**
  * @return string The instance URL for this resource. It needs to be special
  *                cased because it doesn't fit into the standard resource pattern.
  */
 public function instanceUrl()
 {
     if ($result = parent::instanceUrl()) {
         return $result;
     }
     $id = $this['id'];
     $id = Util\Util::utf8($id);
     $extn = urlencode($id);
     $base = self::classUrl();
     return "{$base}/{$extn}";
 }
コード例 #8
0
ファイル: UtilTest.php プロジェクト: xavismeh/stripe-php
 public function testUtf8()
 {
     // UTF-8 string
     $x = "é";
     $this->assertSame(Util\Util::utf8($x), $x);
     // Latin-1 string
     $x = "é";
     $this->assertSame(Util\Util::utf8($x), "é");
     // Not a string
     $x = true;
     $this->assertSame(Util\Util::utf8($x), $x);
 }
コード例 #9
0
 /**
  * @return string The instance URL for this resource. It needs to be special
  *    cased because it doesn't fit into the standard resource pattern.
  */
 public function instanceUrl()
 {
     $result = parent::instanceUrl();
     if ($result) {
         return $result;
     } else {
         $id = $this['id'];
         $id = Util\Util::utf8($id);
         $extn = urlencode($id);
         $base = BitcoinReceiver::classUrl();
         return "{$base}/{$extn}";
     }
 }
コード例 #10
0
ファイル: Subscription.php プロジェクト: xavismeh/stripe-php
 /**
  * {@inheritdoc}
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     $customer = $this['customer'];
     if (!$id) {
         throw new Error\InvalidRequest('Could not determine which URL to request: ' . "class instance has invalid ID: {$id}", null);
     }
     $id = Util\Util::utf8($id);
     $customer = Util\Util::utf8($customer);
     $base = Customer::classUrl();
     $customerExtn = urlencode($customer);
     $extn = urlencode($id);
     return "{$base}/{$customerExtn}/subscriptions/{$extn}";
 }
コード例 #11
0
 /**
  * @return string The API URL for this Stripe transfer reversal.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     $transfer = $this['transfer'];
     if (!$id) {
         throw new Error\InvalidRequest("Could not determine which URL to request: " . "class instance has invalid ID: {$id}", null);
     }
     $id = Util\Util::utf8($id);
     $transfer = Util\Util::utf8($transfer);
     $base = Transfer::classUrl();
     $transferExtn = urlencode($transfer);
     $extn = urlencode($id);
     return "{$base}/{$transferExtn}/reversals/{$extn}";
 }
コード例 #12
0
ファイル: Refund.php プロジェクト: kl0428/urtime
 /**
  * @return string The API URL for this Pingpp refund.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     $charge = $this['charge'];
     if (!$id) {
         throw new Error\InvalidRequest("Could not determine which URL to request: " . "class instance has invalid ID: {$id}", null);
     }
     $id = Util\Util::utf8($id);
     $charge = Util\Util::utf8($charge);
     $base = Charge::classUrl();
     $chargeExtn = urlencode($charge);
     $extn = urlencode($id);
     return "{$base}/{$chargeExtn}/refunds/{$extn}";
 }
コード例 #13
0
ファイル: ApiRequestor.php プロジェクト: jiaoyix/jiaoyix-php
 private static function _encodeObjects($d)
 {
     if ($d instanceof ApiResource) {
         return Util\Util::utf8($d->id);
     } elseif ($d === true) {
         return 'true';
     } elseif ($d === false) {
         return 'false';
     } elseif (is_array($d)) {
         $res = array();
         foreach ($d as $k => $v) {
             $res[$k] = self::_encodeObjects($v);
         }
         return $res;
     } else {
         return Util\Util::utf8($d);
     }
 }
コード例 #14
0
ファイル: BitcoinReceiver.php プロジェクト: parsonsc/dofe
 /**
  * @return string The instance URL for this resource. It needs to be special
  *    cased because it doesn't fit into the standard resource pattern.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     if (!$id) {
         $class = get_class($this);
         $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}";
         throw new Error\InvalidRequest($msg, null);
     }
     $id = Util\Util::utf8($id);
     $extn = urlencode($id);
     if (!$this['customer']) {
         $base = BitcoinReceiver::classUrl();
         return "{$base}/{$extn}";
     } else {
         $base = Customer::classUrl();
         $parent = Util\Util::utf8($this['customer']);
         $parentExtn = urlencode($parent);
         return "{$base}/{$parentExtn}/sources/{$extn}";
     }
 }
コード例 #15
0
 /**
  * @since 1.0
  * @uses  Util::pack()
  * 
  * @return binary
  */
 public function toBinary()
 {
     return Util\Util::pack(0x4d, 0x54, 0x68, 0x64) . Util\Util::pack(0x0, 0x0, 0x0, 0x6) . Util\Util::pack(0x0, $this->midiFormat) . Util\Util::pack($this->numTracks >> 8, $this->numTracks & 0xff) . Util\Util::pack($this->timeDivision >> 8, $this->timeDivision & 0xff);
 }
コード例 #16
0
 /**
  * @param array|null $params
  * @param array|string|null $opts
  *
  * @return Invoice The upcoming invoice.
  */
 public static function upcoming($params = null, $opts = null)
 {
     $url = static::classUrl() . '/upcoming';
     list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
     return Util\Util::convertToStripeObject($response, $opts);
 }
コード例 #17
0
 private function _curlRequest($method, $absUrl, $headers, $params)
 {
     $curl = curl_init();
     $method = strtolower($method);
     $opts = array();
     $requestSignature = NULL;
     if ($method == 'get') {
         $opts[CURLOPT_HTTPGET] = 1;
         if (count($params) > 0) {
             $encoded = self::encode($params);
             $absUrl = "{$absUrl}?{$encoded}";
         }
     } elseif ($method == 'post' || $method == 'put') {
         if ($method == 'post') {
             $opts[CURLOPT_POST] = 1;
         } else {
             $opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
         }
         $rawRequestBody = json_encode($params);
         $opts[CURLOPT_POSTFIELDS] = $rawRequestBody;
         if ($this->privateKey()) {
             $signResult = openssl_sign($rawRequestBody, $requestSignature, $this->privateKey(), 'sha256');
             if (!$signResult) {
                 throw new Error\Api("Generate signature failed");
             }
         }
     } elseif ($method == 'delete') {
         $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
         if (count($params) > 0) {
             $encoded = self::encode($params);
             $absUrl = "{$absUrl}?{$encoded}";
         }
     } else {
         throw new Error\Api("Unrecognized method {$method}");
     }
     if ($requestSignature) {
         $headers[] = 'Pingplusplus-Signature: ' . base64_encode($requestSignature);
     }
     $absUrl = Util\Util::utf8($absUrl);
     $opts[CURLOPT_URL] = $absUrl;
     $opts[CURLOPT_RETURNTRANSFER] = true;
     $opts[CURLOPT_CONNECTTIMEOUT] = 30;
     $opts[CURLOPT_TIMEOUT] = 80;
     $opts[CURLOPT_HTTPHEADER] = $headers;
     if (!Pingpp::$verifySslCerts) {
         $opts[CURLOPT_SSL_VERIFYPEER] = false;
     }
     curl_setopt_array($curl, $opts);
     $rbody = curl_exec($curl);
     if (!defined('CURLE_SSL_CACERT_BADFILE')) {
         define('CURLE_SSL_CACERT_BADFILE', 77);
         // constant not defined in PHP
     }
     $errno = curl_errno($curl);
     if ($errno == CURLE_SSL_CACERT || $errno == CURLE_SSL_PEER_CERTIFICATE || $errno == CURLE_SSL_CACERT_BADFILE) {
         array_push($headers, 'X-Pingpp-Client-Info: {"ca":"using Pingpp-supplied CA bundle"}');
         $cert = $this->caBundle();
         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($curl, CURLOPT_CAINFO, $cert);
         $rbody = curl_exec($curl);
     }
     if ($rbody === false) {
         $errno = curl_errno($curl);
         $message = curl_error($curl);
         curl_close($curl);
         $this->handleCurlError($errno, $message);
     }
     $rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     curl_close($curl);
     return array($rbody, $rcode);
 }
コード例 #18
0
 /**
  * @since 1.0
  * @uses  Util::pack()
  * 
  * @return binary
  */
 public function toBinary()
 {
     return Util\Util::pack(0x4d, 0x54, 0x72, 0x6b) . Util\Util::pack($this->size >> 24) . Util\Util::pack($this->size >> 16 & 0xff) . Util\Util::pack($this->size >> 8 & 0xff) . Util\Util::pack($this->size & 0xff);
 }
コード例 #19
0
ファイル: ApiResource.php プロジェクト: onlineshine/myzf
 protected static function _create($params = null, $options = null)
 {
     self::_validateParams($params);
     $base = static::baseUrl();
     $url = static::classUrl();
     list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
     return Util\Util::convertToPingppObject($response, $opts);
 }
コード例 #20
0
ファイル: Document.php プロジェクト: yay-couch/couch
 /**
  * Find a document's attachments.
  *
  * @link   http://docs.couchdb.org/en/1.5.1/api/document/common.html#attachments
  * @param  bool  $attEncInfo
  * @param  array $attsSince
  * @return array
  */
 public function findAttachments($attEncInfo = false, array $attsSince = null)
 {
     $query = [];
     $query['attachments'] = true;
     $query['att_encoding_info'] = $attEncInfo;
     // include revisions
     if (!empty($attsSince)) {
         $attsSinceArray = [];
         foreach ($attsSince as $attsSinceValue) {
             $attsSinceArray[] = sprintf('"%s"', Util\Util::quote($attsSinceValue));
         }
         $query['atts_since'] = sprintf('[%s]', join(',', $attsSinceArray));
     }
     $data = $this->find($query);
     if (isset($data['_attachments'])) {
         return $data['_attachments'];
     }
 }
コード例 #21
0
ファイル: Delta.php プロジェクト: darwinkim/onlinesequencer
 /**
  * @since 1.0
  * @uses  Util::getDeltaByteSequence()
  * 
  * @return Util
  */
 public function toBinary()
 {
     return Util\Util::getDeltaByteSequence($this->ticks);
 }
コード例 #22
0
 public function __toArray($recursive = false)
 {
     if ($recursive) {
         return Util\Util::convertStripeObjectToArray($this->_values);
     } else {
         return $this->_values;
     }
 }
コード例 #23
0
ファイル: ApiResource.php プロジェクト: cso4tb/Auxum-
 protected static function _create($params = null, $options = null)
 {
     self::_validateParams($params);
     $base = static::baseUrl();
     $url = static::classUrl();
     list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
     $obj = Util\Util::convertToStripeObject($response->json, $opts);
     $obj->setLastResponse($response);
     return $obj;
 }
コード例 #24
0
ファイル: ApiResource.php プロジェクト: ubivar/ubivar-php
 protected function _delete($params = null, $options = null)
 {
     self::_validateParams($params);
     $url = $this->instanceUrl();
     list($response, $opts) = $this->_request('delete', $url, $params, $options);
     $result = Util\Util::convertToUbivarObject($response, $opts);
     return $result[0];
 }
コード例 #25
0
 /**
  * @param array $answers The answers to pass.
  *
  * @return QuestionSet The scored QuestionSet.
  */
 protected function _score($answers)
 {
     $url = static::instanceUrl() . '/score';
     // Weird request requires us to build the cURL request manually
     $params = '';
     foreach ($answers as $key => $value) {
         $params = $params . 'answers[][{$key}]={$value}&';
     }
     rtrim($params, '&');
     $response = static::_makeRequest('post', $url, $params);
     return Util\Util::convertToBlockScoreObject($response);
 }
コード例 #26
0
ファイル: ApiRequestor.php プロジェクト: BrianLTJ/99dayin
 private function _requestRaw($method, $url, $params, $headers)
 {
     if (!array_key_exists($this->_apiBase, self::$_preFlight) || !self::$_preFlight[$this->_apiBase]) {
         self::$_preFlight[$this->_apiBase] = $this->checkSslCert($this->_apiBase);
     }
     $myApiKey = $this->_apiKey;
     if (!$myApiKey) {
         $myApiKey = Pingpp::$apiKey;
     }
     if (!$myApiKey) {
         $msg = 'No API key provided.  (HINT: set your API key using ' . '"Pingpp::setApiKey(<API-KEY>)".  You can generate API keys from ' . 'the Pingpp web interface.  See https://pingxx.com/document/api for ' . 'details, or email support@pingxx.com if you have any questions.';
         throw new Error\Authentication($msg);
     }
     $absUrl = $this->_apiBase . $url;
     $params = self::_encodeObjects($params, $method == 'post');
     $langVersion = phpversion();
     $uname = php_uname();
     $ua = array('bindings_version' => Pingpp::VERSION, 'lang' => 'php', 'lang_version' => $langVersion, 'publisher' => 'pingplusplus', 'uname' => $uname);
     $defaultHeaders = array('X-Pingpp-Client-User-Agent' => json_encode($ua), 'User-Agent' => 'Pingpp/v1 PhpBindings/' . Pingpp::VERSION, 'Authorization' => 'Bearer ' . $myApiKey);
     if (Pingpp::$apiVersion) {
         $defaultHeaders['Pingplusplus-Version'] = Pingpp::$apiVersion;
     }
     if ($method == 'post') {
         $defaultHeaders['Content-type'] = 'application/json;charset=UTF-8';
     }
     $requestHeaders = Util\Util::getRequestHeaders();
     if (isset($requestHeaders['Pingpp-Sdk-Version'])) {
         $defaultHeaders['Pingpp-Sdk-Version'] = $requestHeaders['Pingpp-Sdk-Version'];
     }
     if (isset($requestHeaders['Pingpp-One-Version'])) {
         $defaultHeaders['Pingpp-One-Version'] = $requestHeaders['Pingpp-One-Version'];
     }
     $combinedHeaders = array_merge($defaultHeaders, $headers);
     $rawHeaders = array();
     foreach ($combinedHeaders as $header => $value) {
         $rawHeaders[] = $header . ': ' . $value;
     }
     list($rbody, $rcode) = $this->_curlRequest($method, $absUrl, $rawHeaders, $params);
     return array($rbody, $rcode, $myApiKey);
 }
コード例 #27
0
ファイル: Order.php プロジェクト: jesusmarket/jesusmarket
 /**
  * @return OrderReturn The newly created return.
  */
 public function returnOrder($params = null, $opts = null)
 {
     $url = $this->instanceUrl() . '/returns';
     list($response, $opts) = $this->_request('post', $url, $params, $opts);
     return Util\Util::convertToStripeObject($response, $opts);
 }
コード例 #28
0
ファイル: base.php プロジェクト: dalinhuang/yike
<?php

$start = microtime(true);
//开启会话
session_start();
// 定义系统常量
define("DOCROOT", __DIR__ . DIRECTORY_SEPARATOR);
define("SYSPATH", DOCROOT . "system" . DIRECTORY_SEPARATOR);
define("APPPATH", DOCROOT . "app" . DIRECTORY_SEPARATOR);
define("MODEL", SYSPATH);
define("LIBPATH", SYSPATH . 'libs' . DIRECTORY_SEPARATOR);
define("CONFILE", SYSPATH . "config.php");
//加载库 PHPActiveRecord TODO: 按需加载库
require_once LIBPATH . 'PHPActiveRecord' . DIRECTORY_SEPARATOR . 'ActiveRecord.php';
//自动加载类
require_once SYSPATH . 'Autoload.php';
spl_autoload_register('loadClassFile');
//获取配置
$GLOBALS['config'] = (include CONFILE);
//根据配置文件进行设置
Util\Util::$env = $GLOBALS['config']['env'];
//PHPActiveRecord 配置
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory($GLOBALS['config']['moddir']);
    $cfg->set_connections($GLOBALS['config']['dbconfig']);
    $cfg->set_default_connection(!isset($_SERVER['HTTP_APPNAME']) ? 'local' : 'sae');
});
// CURRENT_YIKE 为当前用户的 id
define('CURRENT_YIKE', isset($_SESSION['yike_id']) ? intval($_SESSION['yike_id']) : null);
コード例 #29
0
 /**
  * @param array $answers The answers to pass.
  *
  * @return QuestionSet The scored QuestionSet.
  */
 protected function _score($answers)
 {
     $url = static::instanceUrl() . '/score';
     // Weird request requires us to build the cURL request manually
     $params = array();
     foreach ($answers as $key => $value) {
         $params[] = "answers[][question_id]={$value['question_id']}";
         $params[] = "answers[][answer_id]={$value['answer_id']}";
     }
     $response = static::_makeRequest('post', $url, implode('&', $params));
     return Util\Util::convertToBlockScoreObject($response);
 }