diff options
author | thomas <thomas@thomas-VirtualBox.(none)> | 2012-11-12 15:37:44 +0100 |
---|---|---|
committer | thomas <thomas@thomas-VirtualBox.(none)> | 2012-11-12 15:37:44 +0100 |
commit | 4564898c288ab4cd221eeba91ab728331f12dba5 (patch) | |
tree | 6142ded45176398c89157cc5197f82d4b6838653 /lib/ocsclient.php | |
parent | 2d523656066ca3c917c43dd3c6f794148d0a2841 (diff) | |
download | nextcloud-server-4564898c288ab4cd221eeba91ab728331f12dba5.tar.gz nextcloud-server-4564898c288ab4cd221eeba91ab728331f12dba5.zip |
Use curl to get remote file content
Diffstat (limited to 'lib/ocsclient.php')
-rw-r--r-- | lib/ocsclient.php | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/ocsclient.php b/lib/ocsclient.php index b6b5ad8f0a9..283f95d5851 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -55,19 +55,29 @@ class OC_OCSClient{ * This function calls an OCS server and returns the response. It also sets a sane timeout */ private static function getOCSresponse($url) { - // set a sensible timeout of 10 sec to stay responsive even if the server is down. - $ctx = stream_context_create( - array( - 'http' => array( - 'timeout' => 10 - ) - ) - ); - $data=@file_get_contents($url, 0, $ctx); + $data = self::fileGetContentCurl($url); return($data); } - + /** + * @Brief Get file content via curl. + * @return string of the response + * This function get the content of a page via curl. + */ + + private static function fileGetContentCurl($url){ + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_URL, $url); + + $data = curl_exec($curl); + curl_close($data); + + return $data; + } + /** * @brief Get all the categories from the OCS server * @returns array with category ids |