public function quotesAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $provider = Request::getProvider(); $provider->setBaseUri('http://api.markets.wallstreetcn.com/v1/'); try { $response = $provider->get('quotes.json'); } catch (\Exception $e) { return $this->view->setVar('quotes', array()); } if ($response->header->statusCode != 200) { return $this->view->setVar('quotes', array()); } $quotes = json_decode($response->body); $quotes = $quotes->results; $selectedQuotes = $this->getDI()->getConfig()->wscn->sidebar->quotes; foreach ($quotes as $key => $quote) { $symbol = $quote->symbol; if (isset($selectedQuotes->{$symbol})) { $quote->keyword = $selectedQuotes->{$symbol}->keyword; $selectedQuotes->{$symbol} = $quote; } } $this->view->setVar('quotes', $selectedQuotes); //$this->view->changeRender('partial/sidebar'); return $selectedQuotes; }
public function getAll() { $provider = Request::getProvider(); $provider->setBaseUri('http://127.0.0.1:5984/t4logs/_design/base/_view/all'); $provider->header->set('Accept', 'application/json'); $response = $provider->get(''); return array("statusCode" => $response->header->statusCode, "body" => $response->body); }
function __construct() { if (!self::isAvailable()) { throw new ProviderException('HTTP or HTTPS stream wrappers not registered'); } $this->context = stream_context_create(); $this->initOptions(); parent::__construct(); }
public function __construct() { if (!self::isAvailable()) { throw new ProviderException('CURL extension is not loaded'); } $this->handle = curl_init(); $this->initOptions(); parent::__construct(); }
public function nodeAction() { $id = $this->dispatcher->getParam('id'); $provider = Request::getProvider(); $provider->setBaseUri('http://api.wallstreetcn.com/apiv1/'); $response = $provider->get("node/{$id}.json"); //$response->header->statusCode; $post = json_decode($response->body); $this->view->setVar('post', $post); }
public function indexAction() { $page = $this->request->getQuery('page', 'int', '0'); $provider = Request::getProvider(); $provider->setBaseUri('http://api.wallstreetcn.com/apiv1/'); $response = $provider->get('livenews-list-v2.json', array('page' => $page)); //$response->header->statusCode; $posts = json_decode($response->body); $this->view->setVar('posts', $posts); $this->view->setVar('page', $page); }
public function __construct() { if (!self::isAvailable()) { throw new ProviderException('CURL extension is not loaded'); } $this->handle = curl_init(); if ($this->handle === false) { throw new HttpException(curl_error($this->handle), 'curl'); } $this->initOptions(); parent::__construct(); }
/** * Validates the user with app secret key and the provided code. * Retrieves the access token and stores it in session * * @var string */ public function instagramLoginResponse($code) { $instaRequest = Request::getProvider(); $instaRequest->setBaseUri('https://api.instagram.com/'); $response = $instaRequest->post('oauth/access_token', array('client_id' => $this->config->instagram->get('properties')['CLIENT-ID'], 'client_secret' => $this->config->instagram->get('properties')['clientSecret'], 'grant_type' => 'authorization_code', 'redirect_uri' => $this->config->instagram->get('properties')['REDIRECT-AUTH-URI'], 'code' => $code)); if ($response->header->statusCode == 200) { $body = json_decode($response->body, true); $this->session->set('auth-instagram', $body['access_token']); } //TODO save in DB the user details //$this->dispatcher->forward(array('controller' => 'index', 'action' => 'index')); return $instaRequest; }
public function getPreparedData() { $providerHttp = Request::getProvider(); switch ($this->type) { case 'json': $data = $this->getPreparedJSONTypeData($providerHttp); break; case 'rss': $data = $this->getPreparedRSSTypeData($providerHttp); break; case 'file': $data = $this->getPreparedFileTypeData($this->data); break; default: $data = false; } return $data; }
<?php /** * Bootstrap for the test environment. * * @package PhouchDb * @subpackage Tests * @author Mike Holloway <*****@*****.**> */ require_once __DIR__ . '/../vendor/autoload.php'; $envConfig = __DIR__ . '/configs/testing.config.php'; $config = new \Phalcon\Config(include __DIR__ . '/configs/config.php'); // merge local config, if it exists if (file_exists($envConfig)) { $config->merge(new \Phalcon\Config(include $envConfig)); } unset($envConfig); $di = new \Phalcon\DI(); // store the config so it doesn't have to be parsed again $di->set('config', $config); $di->set('collectionManager', function () { return new \Phalcon\Mvc\Collection\Manager(); }); $di->set('couchdb', function () use($config) { $client = \Phalcon\Http\Client\Request::getProvider(); $client->setBaseUri($config->couchdb->baseUri); $client->header->set('Content-Type', 'application/json'); return $client; });
protected function instagramGetRequest($baseUri, $params = null) { $request = Request::getProvider(); $request->setBaseUri($baseUri); $request->header->set('Accept', 'application/json'); $response = $request->get($baseUri, $params); $response = json_decode($response->body, true); return $response; }