Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dakota_Tools_Helper_Data extends Mage_Core_Helper_Abstract
- {
- public function curlGetUrlContent($url, $header = false)
- {
- $crl = curl_init();
- $timeout = 5;
- curl_setopt ($crl, CURLOPT_URL,$url);
- curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
- if($header) {
- curl_setopt($crl, CURLOPT_HTTPHEADER, $header);
- }
- $ret = curl_exec($crl);
- curl_close($crl);
- return $ret;
- }
- function curlPutUrlContent($url, $fields, $header = false)
- {
- $fields_string = http_build_query($fields);
- $crl = curl_init();
- $timeout = 5;
- curl_setopt($crl, CURLOPT_URL, $url);
- curl_setopt($crl, CURLOPT_CUSTOMREQUEST, "PUT");
- curl_setopt($crl, CURLOPT_POSTFIELDS, $fields_string);
- curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
- if($header) {
- curl_setopt($crl, CURLOPT_HTTPHEADER, $header);
- }
- $ret = curl_exec($crl);
- curl_close($crl);
- return $ret;
- }
- function curlPostUrlContent($url, $fields, $header = false)
- {
- $fields_string = '';
- foreach($fields as $key=>$value) {
- $fields_string .= $key.'='.urlencode($value).'&';
- }
- rtrim($fields_string, '&');
- $crl = curl_init();
- $timeout = 5;
- curl_setopt($crl, CURLOPT_URL,$url);
- curl_setopt($crl, CURLOPT_POST, count($fields));
- curl_setopt($crl, CURLOPT_POSTFIELDS, $fields_string);
- curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
- $ret = curl_exec($crl);
- curl_close($crl);
- return $ret;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement