Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function srp_wp_http_xml($url){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
- $result = curl_exec($ch);
- $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- if(!$code){
- preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
- $host = $matches[1];
- preg_match('/[^.]+\.[^.]+$/', $host, $matches);
- srp_debug(__('Something went wrong. No data is being returned from ' . $matches[0] . '.'), $result);
- return;
- }elseif($code != 200){
- $message = 'Request to URL: "' . $url . '" failed. Response code: ' . $code;
- srp_debug(__($message), $result);
- return;
- }
- $xml = @simplexml_load_string($result);
- return $xml;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement