Skip to content

Instantly share code, notes, and snippets.

@onema
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onema/a5176f97a68d98f3a83c to your computer and use it in GitHub Desktop.
Save onema/a5176f97a68d98f3a83c to your computer and use it in GitHub Desktop.
SDPHP Study Group - Test Controller
<?php
namespace SDPHP\PhotoOpBundle\Controller;
use GuzzleHttp\Client;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller
{
//
public function testAction()
{
// Guzzle 4 client
$client = new Client();
// Make a GET request to API, This will eventually be in a service description
$guzzleResponse = $client->get('https://api.flickr.com/services/rest/?method=flickr.photosets...');
// Get the content of the response body (xml)
$symfonyResponse = new Response($guzzleResponse->getBody());
// set the content type of the response to display the xml in the web browser
$symfonyResponse->headers->set('content-type', 'text/xml');
return $symfonyResponse;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment