Last active
August 29, 2015 14:03
-
-
Save onema/a5176f97a68d98f3a83c to your computer and use it in GitHub Desktop.
SDPHP Study Group - Test Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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