public function testCanParseJson()
 {
     $json = Parse::toJSON($this->arrayMulti);
     $array = Parse::fromJSON($json);
     $this->assertEquals($this->arrayMulti, $array);
 }
예제 #2
0
 /**
  * Execute the Request against the API
  *
  * @param boolean $parse
  *
  * @return array
  */
 protected function execute($parse = true)
 {
     $user = $this->user;
     $consumer = $this->consumer;
     $parameters = $this->parameters;
     return $this->app['cache']->remember($parse . $this->hash, $this->getCacheLifetime(), function () use($parse, $user, $consumer, $parameters) {
         // Create OAuth request
         $request = new TmhOAuth(array('consumer_key' => $consumer->getKey(), 'consumer_secret' => $consumer->getSecret(), 'host' => Flickering::API_URL, 'use_ssl' => true, 'user_token' => $user->getKey(), 'user_secret' => $user->getSecret()));
         $request->request('GET', $request->url(''), $parameters);
         $response = $request->response['response'];
         // Return raw if requested
         if (!$parse) {
             return $response;
         }
         // Parse resulting content
         switch (array_get($parameters, 'format')) {
             case 'json':
                 return Parse::fromJSON($response);
             default:
                 return Parse::fromXML($response);
         }
     });
 }