Skip to content

Instantly share code, notes, and snippets.

@miholeus
Created April 11, 2012 12:10
Show Gist options
  • Save miholeus/2358976 to your computer and use it in GitHub Desktop.
Save miholeus/2358976 to your computer and use it in GitHub Desktop.
remote file download
if(!empty($remote)) {
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HEADER => 0,
CURLOPT_CONNECTTIMEOUT => 5,
),
);
$client = new \Zend_Http_Client($remote, $config);
try {
$client->request();
} catch (\Exception $e) {
throw new ProductsService\RemoteFileException($e->getMessage());
}
$response = $client->getLastResponse();
$contentType = $response->getHeader('Content-type');
$contentBody = $response->getRawBody();
var_dump($contentType);
var_dump($contentBody);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment