public function testGetWithException() { $error = ['message' => 'Test message', 'code' => 'test_code', 'fields' => ['field1' => 'error1']]; $http = $this->createHttpMock('https://api.uber.com/v1/foo', 555, json_encode($error)); $uber = new Uber('my_token', 'v1', Uber::PRODUCTION_API, $http); try { $uber->get('/foo'); $this->fail('No exception'); } catch (ApiException $e) { $this->assertEquals('Test message', $e->getErrorMessage()); $this->assertEquals('test_code', $e->getErrorCode()); $this->assertEquals((object) ['field1' => 'error1'], $e->getFields()); $this->assertEquals(555, $e->getHttpCode()); } }
public static function init() { if (self::$_inited) { return; } require_once dirname(__FILE__) . DS . 'Uber' . DS . 'Loader.php'; self::initUberAutoload(); Uber_Loader::registerAutoload(); self::$_inited = true; }
<meta name="msapplication-tap-highlight" content="no" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <style>a,body,div,footer,h1,h2,h3,h4,h5,h6,header,html,img,input,li,p,section,select,span,textarea,ul{margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,0,0,0);border:none;outline:0;-webkit-touch-callout:none}html{min-height:100%}body{min-height:100%;font-family:'\5FAE\8F6F\96C5\9ED1','黑体','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:30px;background:#f5f5eb}a,body{color:#000}.fixed-bottom,.fixed-screen-bottom{position:fixed;width:100%;height:100%;left:0;bottom:0}.clearfix:after,.clearfix:before{display:table;line-height:0;content:""}.clearfix:after{clear:both}a{text-decoration:none}img{max-width:100%}li{list-style:none}.fl{float:left}.fr{float:right}.radius5{border-radius:5px}.radius10{border-radius:10px}.hide{display:none}.show{display:block}.show-in{display:inline-block}.fixed-bottom{-webkit-backface-visibility:hidden}.fixed-bottom.blackbg{background:#292928;background:rgba(41,41,40,.95)}.icon,.icon-del-img{display:inline-block}.icon{background:url(http://cdnst.momocdn.com/static/m4/img/icon.png?20150126) no-repeat;background-size:250px auto;vertical-align:middle}</style> <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script> <?php define('APP_DIR', dirname(__FILE__)); require_once APP_DIR . '/action/weixin.php'; require_once APP_DIR . '/action/uber.php'; $appid = 'wx895ed4a1115b7e54'; $appsecret = 'd4624c36b6795d1d99dcf0547af5443d'; $weixin = new Weixin($appid, $appsecret); $uber_appid = 'cmLDMkZ4cr9rivGlPd8Z6AQM-gdwiU2t'; $uber_appsecret = 'q7ImotFQf1BsgKhsT0STUrq0Vd8IquRSpcoBdS4A'; $uber = new Uber($uber_appid, $uber_appsecret, 'profile'); if (get('code') && get('state') == 'authorization') { $uber->oauth(); exit; } $uber->gotoOAuth(); $jsSDK = $weixin->getJsApiConf(); ?> <script> var UberHackthon = { ajax : function( url, data, callback, method, errorCallback ) { var xhr = new window.XMLHttpRequest; var sdata = data || '' ; xhr.onreadystatechange = function(){
public static function resetAutoloadPatterns() { self::$_autoloadPatterns = array('classes' => array(), 'dynamic' => array()); self::$_namespaces = array(); Uber::initUberAutoload(); }
<?php define('PROJECT_PATH', dirname(dirname(__FILE__))); // sgl libs $root = dirname(dirname(dirname(__FILE__))); $sglLibDir = $root . '/sgl2/src/lib'; require $sglLibDir . '/Uber.php'; Uber::init(); Uber_Loader::registerNamespace('SGL2', $sglLibDir); Uber_Loader::registerNamespace('Zend', $sglLibDir); Uber_Loader::registerNamespace('Horde', $sglLibDir); try { $front = new SGL2_Controller_Front(); $output = $front->bootstrap()->dispatch(); } catch (Exception $e) { print '<pre>'; print_r($e); } echo $output;