Advertisement
Guest User

Untitled

a guest
Jan 28th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 19.13 KB | None | 0 0
  1. <?php
  2.     defined( '_JEXEC' ) or die( 'Restricted access' ); // No direct access
  3.    
  4.     require_once( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_estore' . DS . 'classes' . DS . 'store_options.class.php');
  5.    
  6.     class shipping_richwrap extends shipping_method {
  7.        
  8.         function __construct() {
  9.             $this->id = "richwrap";
  10.             $this->name = "Richwrap";
  11.         }
  12.        
  13.         public function calculate($ship_method, $ship_date, $address, $weight, $total_shipment_weight) {
  14.             //ship method is only fedex ground for now
  15.             /**
  16.              * Address: array
  17.              *  id
  18.              *  quantity
  19.              *  ship_name
  20.              *  ship_address_1
  21.              *  ship_address_2
  22.              *  ship_city
  23.              *  ship_state
  24.              *  ship_postal
  25.              */
  26.             if ($address['ship_address_1'] == 'Address 1') $address['ship_address_1'] = '';
  27.             if ($address['ship_address_2'] == 'Address 2') $address['ship_address_2'] = '';
  28.             if ($address['ship_city'] == 'City') $address['ship_city'] = '';
  29.             if ($address['ship_state'] == 'State') $address['ship_state'] = '';
  30.             if ($address['ship_postal'] == 'Zip') $address['ship_postal'] = '';
  31.            
  32.            
  33.             //perform basic checking of the address before moving forward
  34.             if (
  35.                 strlen($address['ship_name']) > 2 &&
  36.                 strlen($address['ship_address_1']) > 5 &&
  37.                 strlen($address['ship_city']) > 1 &&
  38.                 strlen($address['ship_state']) > 1 &&
  39.                 strlen($address['ship_postal']) >= 5
  40.                 ) {
  41.                
  42.                 //looks somewhat valid, further checking
  43.                 $options = array(
  44.                     'address_1' => $address['ship_address_1'],
  45.                     'address_2' => $address['ship_address_2'],
  46.                     'city' => $address['ship_city'],
  47.                     'state' => $address['ship_state'],
  48.                     'postal' => $address['ship_postal']
  49.                 );
  50.                
  51.                 $result = self::get_cache($this->id . '_address', $options);
  52.                
  53.                 if (!$result) {
  54.                     $result = self::verify_address($options);
  55.                     self::update_cache($this->id . '_address', $options, $result);
  56.                 }
  57.                
  58.                 $clean_address = self::get_address($result);
  59.                
  60.                 if ($clean_address) {
  61.                     $total_weight = $weight;
  62.                    
  63.                     $options = array($clean_address, $total_weight);
  64.                    
  65.                     $result = self::get_cache($this->id . '_shipping', $options);
  66.                    
  67.                     if (!$result) {
  68.                         $result = fedex::get_result($clean_address, $total_weight);
  69.                         self::update_cache($this->id . '_shipping', $options, $result);
  70.                     }
  71.                    
  72.                     $rates = fedex::get_rates($result);
  73.                     if (isset($rates['FEDEX_GROUND']) || isset($rates['GROUND_HOME_DELIVERY'])) {
  74.                         if (isset($rates['FEDEX_GROUND']))
  75.                             $rate = floatval($rates['FEDEX_GROUND']);
  76.                         else
  77.                             $rate = floatval($rates['GROUND_HOME_DELIVERY']);
  78.                        
  79.                         $overweight = floatval(store_options::get('Shipping - Costs', 'Overweight Limit (lbs)', '200'));
  80.                         $residential_padding = floatval(store_options::get('Shipping - Costs', 'Residential Padding (Percent)', '12.5')) / 100;
  81.                         $residential_overweight_padding = floatval(store_options::get('Shipping - Costs', 'Residential Overweight Padding (Percent)', '20')) / 100;
  82.                         $commercial_padding = floatval(store_options::get('Shipping - Costs', 'Commercial Padding (Percent)', '20')) / 100;
  83.                         $commercial_overweight_padding = floatval(store_options::get('Shipping - Costs', 'Commercial Overweight Padding (Percent)', '20')) / 100;
  84.                        
  85.                         if ($total_shipment_weight < $overweight) {
  86.                             if ($clean_address['type'] == 'R')
  87.                                 $rate += $rate * $residential_padding;
  88.                             else
  89.                                 $rate += $rate * $commercial_padding;
  90.                         } else {
  91.                             if ($clean_address['type'] == 'R')
  92.                                 $rate += $rate * $residential_overweight_padding;
  93.                             else
  94.                                 $rate += $rate * $commercial_overweight_padding;
  95.                         }
  96.                        
  97.                         return number_format($rate,2);
  98.                     }
  99.                 }
  100.             }
  101.  
  102.             return false;
  103.         }
  104.  
  105.         public function get_address($result) {
  106.             $address = false;
  107.            
  108.             try {
  109.                 $flat_xml = self::flatten_xml($result);
  110.                 if (isset($flat_xml['Response|ReturnCode'])) {
  111.                     $return_code = $flat_xml['Response|ReturnCode'];
  112.                    
  113.                     if ($return_code == '31' || $return_code == '32') {
  114.                         $address = isset($flat_xml['Response|AddrLine1']) ? $flat_xml['Response|AddrLine1'] : '';
  115.                         $address2 = isset($flat_xml['Response|AddrLine2']) ? $flat_xml['Response|AddrLine2'] : '';
  116.                         $city = isset($flat_xml['Response|City']) ? $flat_xml['Response|City'] : '';
  117.                         $state = isset($flat_xml['Response|State']) ? $flat_xml['Response|State'] : '';
  118.                         $zip = isset($flat_xml['Response|ZIP5']) ? $flat_xml['Response|ZIP5'] : '';
  119.                        
  120.                         $rdi = isset($flat_xml['Response|RDI']) ? $flat_xml['Response|RDI'] : '';
  121.                        
  122.                         $address = array(
  123.                             'address' => $address,
  124.                             'address2' => $address2,
  125.                             'city' => $city,
  126.                             'state' => $state,
  127.                             'zip' => $zip,
  128.                             'type' => $rdi
  129.                         );                 
  130.                     }
  131.                 }
  132.             } catch (Exception $e) {
  133.                
  134.             }
  135.            
  136.             return $address;
  137.         }
  138.  
  139.         function verify_address($options) {
  140.             $addr0 = "";
  141.             $addr1 = urlencode(($options['address_2'] != '') ? $options['address_1'] : '');
  142.             $addr2 = urlencode(($options['address_2'] != '') ? $options['address_2'] : $options['address_1']);
  143.             $addr3 = urlencode($options['city'] . ', ' .$options['state'] . ' ' . $options['postal']);
  144.            
  145.             $licensecode = store_options::get('Shipping', 'Address Verification - License Code', 'djh43uxjn4');
  146.            
  147.             $url = "http://www.nrgsoft.com/webservices/address_validation.lasso?AddrLine3=$addr0&AddrLine2=$addr1&AddrLine1=$addr2&AddrLineLast=$addr3&licensecode=$licensecode";
  148.             $ch = curl_init($url);
  149.             curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  150.             curl_setopt($ch,CURLOPT_TIMEOUT,60);
  151.             curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
  152.             curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
  153.             $response=curl_exec($ch);
  154.             curl_close($ch);
  155.            
  156.             return $response ;
  157.         }
  158.  
  159.         private function flatten_xml($content) {
  160.             $xml_start = strpos($content, '<?xml' );
  161.             if ($xml_start === FALSE)
  162.                 $xml_start = 0;
  163.            
  164.             $xml_content = substr($content, $xml_start);
  165.            
  166.             $xml = new XMLReader();
  167.             if ($xml->xml($xml_content)) {
  168.                
  169.                 $values = array();
  170.                 $parents = array();
  171.                 while ($xml->read()) {
  172.                     if ($xml->nodeType == XMLReader::ELEMENT) {
  173.                         array_push($parents, $xml->name);
  174.                     } elseif ($xml->nodeType == XMLReader::END_ELEMENT) {
  175.                         array_pop($parents);
  176.                     } elseif ($xml->nodeType == XMLReader::TEXT) {
  177.                         $key = join('|', $parents);
  178.                         $values[$key] = $xml->value;
  179.                     }
  180.                 }
  181.                
  182.                 $xml->close();
  183.                
  184.                 return $values;
  185.             } else {
  186.                 $xml->close();
  187.                
  188.                 return false;
  189.             }
  190.         }
  191.     }
  192.  
  193.     class fedex {
  194.        
  195.         public static function get_rates($xml) {
  196.             $xmlresult = self::xml2array($xml);
  197.  
  198.             $error = "";
  199.             if (isset($xmlresult['v8:RateReply']['v8:HighestSeverity']['value']))
  200.                 $error = $xmlresult['v8:RateReply']['v8:HighestSeverity']['value'];        
  201.        
  202.             //if ($error != 'SUCCESS' && $error != 'WARNING') {
  203.             //  return false;
  204.             //}
  205.                
  206.             $rates = array();          
  207.             for ($i=0;$i<count($xmlresult['v8:RateReply']['v8:RateReplyDetails']);$i++) {
  208.                 if (isset($xmlresult['v8:RateReply']['v8:RateReplyDetails'][$i])) {
  209.                 $servicecode=$xmlresult['v8:RateReply']['v8:RateReplyDetails'][$i]['v8:ServiceType']['value'];
  210.                
  211.                 $totalcharges = 0;
  212.                 if (isset($xmlresult['v8:RateReply']['v8:RateReplyDetails'][$i]['v8:RatedShipmentDetails'][0]['v8:ShipmentRateDetail']['v8:TotalNetCharge']['v8:Amount']['value']))
  213.                     $totalcharges=$xmlresult['v8:RateReply']['v8:RateReplyDetails'][$i]['v8:RatedShipmentDetails'][0]['v8:ShipmentRateDetail']['v8:TotalNetCharge']['v8:Amount']['value'];
  214.                
  215.                 $gndtotalcharges = 0;
  216.                 if (isset($xmlresult['v8:RateReply']['v8:RateReplyDetails'][$i]['v8:RatedShipmentDetails']['v8:ShipmentRateDetail']['v8:TotalNetCharge']['v8:Amount']['value']))
  217.                     $gndtotalcharges=$xmlresult['v8:RateReply']['v8:RateReplyDetails'][$i]['v8:RatedShipmentDetails']['v8:ShipmentRateDetail']['v8:TotalNetCharge']['v8:Amount']['value'];
  218.    
  219.            
  220.                 if  ( $gndtotalcharges > $totalcharges ) { 
  221.                     $totalcharges = $gndtotalcharges ;
  222.                 }
  223.                            
  224.                 $rates[$servicecode] = $totalcharges;
  225.                 }
  226.             }
  227.            
  228.             return $rates;
  229.         }
  230.            
  231.         private static function xml2array($contents, $get_attributes=1, $priority = 'attribute', $array_force=array()) {
  232.              if(!$contents) return array();
  233.        
  234.             if(!function_exists('xml_parser_create')) {
  235.                 //print "'xml_parser_create()' function not found!";
  236.                 return array();
  237.             }
  238.        
  239.             //Get the XML parser of PHP - PHP must have this module for the parser to work
  240.             $parser = xml_parser_create('');
  241.             xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
  242.             xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  243.             xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  244.             xml_parse_into_struct($parser, trim($contents), $xml_values);
  245.             xml_parser_free($parser);
  246.        
  247.             if(!$xml_values) return;//Hmm...
  248.        
  249.             //Initializations
  250.             $xml_array = array();
  251.             $parents = array();
  252.             $opened_tags = array();
  253.             $arr = array();
  254.        
  255.             $current = &$xml_array; //Refference
  256.        
  257.             //Go through the tags.
  258.             $repeated_tag_index = array();//Multiple tags with same name will be turned into an array
  259.             foreach($xml_values as $data) {
  260.                 unset($attributes,$value);//Remove existing values, or there will be trouble
  261.        
  262.                 //This command will extract these variables into the foreach scope
  263.                 // tag(string), type(string), level(int), attributes(array).
  264.                 extract($data);//We could use the array by itself, but this cooler.
  265.        
  266.                 $result = array();
  267.                 $attributes_data = array();
  268.                  
  269.                 if(isset($value)) {
  270.                     if($priority == 'tag') $result = $value;
  271.                     else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
  272.                 }
  273.        
  274.                 //Set the attributes too.
  275.                 if(isset($attributes) and $get_attributes) {
  276.                     foreach($attributes as $attr => $val) {
  277.                         if($priority == 'tag') $attributes_data[$attr] = $val;
  278.                         else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
  279.                     }
  280.                 }
  281.        
  282.                 //See tag status and do the needed.
  283.         if($type == "open") {//The starting of the tag '<tag>'
  284.         $parent[$level-1] = &$current;
  285.         if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
  286.         if (in_array($tag,$array_force))
  287.         $current[$tag][0] = $result;
  288.         else
  289.         $current[$tag] = $result;
  290.         if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
  291.         $repeated_tag_index[$tag.'_'.$level] = 1;
  292.        
  293.         if (in_array($tag,$array_force))
  294.         $current = &$current[$tag][0];
  295.         else
  296.         $current = &$current[$tag];
  297.        
  298.                     } else { //There was another element with the same tag name
  299.        
  300.                         if(isset($current[$tag][0])) {//If there is a 0th element it is already an array
  301.                             $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
  302.                             $repeated_tag_index[$tag.'_'.$level]++;
  303.                         } else {//This section will make the value an array if multiple tags with the same name appear together
  304.                             $current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array
  305.                             $repeated_tag_index[$tag.'_'.$level] = 2;
  306.                              
  307.                             if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
  308.                                 $current[$tag]['0_attr'] = $current[$tag.'_attr'];
  309.                                 unset($current[$tag.'_attr']);
  310.                             }
  311.        
  312.                         }
  313.                         $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
  314.                         $current = &$current[$tag][$last_item_index];
  315.                     }
  316.        
  317.                 } elseif($type == "complete") { //Tags that ends in 1 line '<tag />'
  318.                     //See if the key is already taken.
  319.                     if(!isset($current[$tag])) { //New Key
  320.                         $current[$tag] = $result;
  321.                         $repeated_tag_index[$tag.'_'.$level] = 1;
  322.                         if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;
  323.        
  324.                     } else { //If taken, put all things inside a list(array)
  325.                         if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...
  326.        
  327.                             // ...push the new element into that array.
  328.                             $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
  329.                              
  330.                             if($priority == 'tag' and $get_attributes and $attributes_data) {
  331.                                 $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
  332.                             }
  333.                             $repeated_tag_index[$tag.'_'.$level]++;
  334.        
  335.                         } else { //If it is not an array...
  336.                             $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
  337.                             $repeated_tag_index[$tag.'_'.$level] = 1;
  338.                             if($priority == 'tag' and $get_attributes) {
  339.                                 if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
  340.                                      
  341.                                     $current[$tag]['0_attr'] = $current[$tag.'_attr'];
  342.                                     unset($current[$tag.'_attr']);
  343.                                 }
  344.                                  
  345.                                 if($attributes_data) {
  346.                                     $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
  347.                                 }
  348.                             }
  349.                             $repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken
  350.                         }
  351.                     }
  352.        
  353.                 } elseif($type == 'close') { //End of tag '</tag>'
  354.                     $current = &$parent[$level-1];
  355.                 }
  356.             }
  357.              
  358.             return($xml_array);
  359.         }  
  360.  
  361.         public static function get_result($address, $weight) {
  362.             /*
  363.                 $address: array
  364.                     address
  365.                     address2
  366.                     city
  367.                     state
  368.                     zip
  369.              */
  370.             $origin_name = store_options::get('Shipping', 'Origin Name', 'RICHWRAP');
  371.             $origin_address = store_options::get('Shipping', 'Origin Address', '401 East North Street');
  372.             $origin_city = store_options::get('Shipping', 'Origin City', 'ELBURN');
  373.             $origin_state = store_options::get('Shipping', 'Origin State', 'IL');
  374.             $origin_postal = store_options::get('Shipping', 'Origin Postal', '60119');
  375.             $origin_country = store_options::get('Shipping', 'Origin Country', 'US');
  376.  
  377.             $fedex_key = store_options::get('Shipping', 'Fedex Key', 'vGFSl41KS0y0cPkA');
  378.             $fedex_password = store_options::get('Shipping', 'Fedex Password', '9PWsF0AMtbSN9IrILssy2wRiR');
  379.             $fedex_account = store_options::get('Shipping', 'Fedex Account', '510087682');
  380.             $fedex_meter = store_options::get('Shipping', 'Fedex Meter', '100034316');
  381.             $fedex_hubid = store_options::get('Shipping', 'Fedex Hub Id', '5303');
  382.             $fedex_server = store_options::get('Shipping', 'Fedex Server (DEV or LIVE)', 'DEV');
  383.             if ($fedex_server != 'LIVE') $fedex_server = 'DEV';
  384.            
  385.             $result = self::quoteFedEx(
  386.                 $origin_name, $origin_address, $origin_city, $origin_state, $origin_postal, $origin_country,
  387.                 $fedex_key, $fedex_password, $fedex_account, $fedex_meter, $fedex_hubid, $fedex_server,
  388.                 $address['address'], $address['city'], $address['state'], $address['zip'], 'US', $address['type'] == 'R',
  389.                 $weight
  390.             );
  391.            
  392.             return $result;
  393.         }
  394.  
  395.         private static function quoteFedEx (
  396.                 $origin_name, $origin_address, $origin_city, $origin_state, $origin_postal, $origin_country,
  397.                 $fedex_key, $fedex_password, $fedex_account, $fedex_meter, $fedex_hubid, $fedex_server,
  398.                 $delivery_address, $delivery_city, $delivery_state, $delivery_zip, $delivery_country, $delivery_residential,
  399.                 $shipping_weight) {
  400.                
  401.             $delivery_zip = substr($delivery_zip, 0, 5);
  402.            
  403.             $today = date ('Y-m-d');
  404.                    
  405.             $Request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  406. <ns:RateRequest xmlns:ns=\"http://fedex.com/ws/rate/v8\"  
  407. xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"  
  408. xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"  
  409. xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
  410. <ns:WebAuthenticationDetail>
  411. <ns:UserCredential>
  412. <ns:Key>$fedex_key</ns:Key>
  413. <ns:Password>$fedex_password</ns:Password>
  414. </ns:UserCredential>
  415. </ns:WebAuthenticationDetail>
  416. <ns:ClientDetail>
  417. <ns:AccountNumber>$fedex_account</ns:AccountNumber>
  418. <ns:MeterNumber>$fedex_meter</ns:MeterNumber>
  419. </ns:ClientDetail>
  420. <ns:TransactionDetail>
  421. <ns:CustomerTransactionId>NRG</ns:CustomerTransactionId>
  422. </ns:TransactionDetail>
  423. <ns:Version>
  424. <ns:ServiceId>crs</ns:ServiceId>
  425. <ns:Major>8</ns:Major>
  426. <ns:Intermediate>0</ns:Intermediate>
  427. <ns:Minor>0</ns:Minor>
  428. </ns:Version>
  429. <ns:ReturnTransitAndCommit>true</ns:ReturnTransitAndCommit>
  430. <ns:RequestedShipment>
  431. <ns:ShipTimestamp>{$today}T10:19:26-05:00</ns:ShipTimestamp>
  432. <ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
  433. <ns:PackagingType>YOUR_PACKAGING</ns:PackagingType>
  434. <ns:Shipper>
  435. <ns:Contact>
  436. <ns:PersonName></ns:PersonName>
  437. <ns:CompanyName>$origin_name</ns:CompanyName>
  438. <ns:PhoneNumber></ns:PhoneNumber>
  439. <ns:EMailAddress></ns:EMailAddress>
  440. </ns:Contact>
  441. <ns:Address>
  442. <ns:StreetLines>$origin_address</ns:StreetLines>
  443. <ns:City>$origin_city</ns:City>
  444. <ns:StateOrProvinceCode>$origin_state</ns:StateOrProvinceCode>
  445. <ns:PostalCode>$origin_postal</ns:PostalCode>
  446. <ns:CountryCode>$origin_country</ns:CountryCode>
  447. </ns:Address>
  448. </ns:Shipper>
  449. <ns:Recipient>
  450. <ns:Address>
  451. <ns:StreetLines>$delivery_address</ns:StreetLines>
  452. <ns:City>$delivery_city</ns:City>
  453. <ns:StateOrProvinceCode>$delivery_state</ns:StateOrProvinceCode>
  454. <ns:PostalCode>$delivery_zip</ns:PostalCode>
  455. <ns:CountryCode>$delivery_country</ns:CountryCode>" ;
  456.  
  457.             if ($delivery_residential) {
  458.                 $Request .= "<ns:Residential>true</ns:Residential>\n";
  459.             }
  460.            
  461.             $Request .="</ns:Address>
  462. </ns:Recipient>
  463. <ns:ShippingChargesPayment>
  464. <ns:PaymentType>SENDER</ns:PaymentType>
  465. <ns:Payor>
  466. <ns:AccountNumber>$fedex_account</ns:AccountNumber>
  467. <ns:CountryCode>US</ns:CountryCode>
  468. </ns:Payor>
  469. </ns:ShippingChargesPayment>
  470. <ns:SmartPostDetail>
  471. <ns:Indicia>PARCEL_SELECT</ns:Indicia>
  472. <ns:SpecialServices>USPS_DELIVERY_CONFIRMATION</ns:SpecialServices>
  473. <ns:HubId>$fedex_hubid</ns:HubId>
  474. </ns:SmartPostDetail>
  475. <ns:RateRequestTypes>ACCOUNT</ns:RateRequestTypes>
  476. <ns:PackageCount>1</ns:PackageCount>
  477. <ns:PackageDetail>INDIVIDUAL_PACKAGES</ns:PackageDetail>
  478. <ns:RequestedPackageLineItems>
  479. <ns:SequenceNumber>1</ns:SequenceNumber>
  480. <ns:Weight>
  481. <ns:Units>LB</ns:Units>
  482. <ns:Value>$shipping_weight</ns:Value>
  483. </ns:Weight>
  484. </ns:RequestedPackageLineItems>
  485. </ns:RequestedShipment>
  486. </ns:RateRequest>";
  487.                                
  488.             if ( $fedex_server == 'DEV' ) {
  489.                 // dev server
  490.                 $url = "https://gatewaybeta.fedex.com/xml";
  491.             } else {
  492.                 // production server
  493.                 $url = "https://gateway.fedex.com/xml";
  494.             }
  495.            
  496.             // execute request
  497.             $ch = curl_init($url);
  498.             curl_setopt($ch, CURLOPT_POST, 1);
  499.             curl_setopt($ch,CURLOPT_TIMEOUT,60);
  500.             curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  501.             curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
  502.             curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
  503.             curl_setopt($ch, CURLOPT_POSTFIELDS, $Request);
  504.             $response = curl_exec($ch);
  505.             curl_close($ch);
  506.            
  507.             return $response;
  508.         }
  509.     }
  510. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement