simplexml on fivedev

Hello,

After moving to fivedev hosting I’m seeing the following error on my site:

Warning: simplexml_load_file() [function.simplexml-load-file]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0

I’m reading an XML file on another domain. Does anyone know how I can work around this?

Thanks

IT looks like Nabeel’s config needs to enable one of allow url fopen.

You are going to have to use curl to get the file,

inside of phpVMS you could use something like;

$url = 'http://www.site.com/file'
$file = new CodonWebService();
$contents = @$file->get($url);

Hello,

After moving to fivedev hosting I’m seeing the following error on my site:

Warning: simplexml_load_file() [function.simplexml-load-file]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0

I’m reading an XML file on another domain. Does anyone know how I can work around this?

Thanks

Are you getting xml route info from vroute?

Yes, you have to use cURL to retrieve the document.

I have to look into enabling stream wrappers in fopen and the like, but it’s generally recommended to have it disabled for security

Okay thanks, I’ll give it a go

Ok so, following this I’ve got this far:

// Check email for known spammer
	$url = 'http://www.stopforumspam.com/api?email='.$email.'&f=xmlcdata';
	$file = new CodonWebService();
	$contents = @$file->get($url);
	echo $contents;

With that last echo being there to see what I’m getting back. Currently I’m getting nothing at all. Yes, $email has a value… Where am I going wrong?

In addition, once I’ve loaded the xml, how am I supposed to do anything with it?

Take out that @, that’s supressing errors

$url = 'http://www.stopforumspam.com/api?email='.$data['email'].'&f=xmlcdata';
		//$params = array('email' => $data['email'], 'f' => 'xmlcdata');
		$file = new CodonWebService();
		$contents = $file->get($url);
		$response = simplexml_load_string($contents);
		echo $contents;

Moved where it is so I’m now using $data[‘email’], but echoing contents still just returns nothing :?

Are you using that URL properly?

With this code:

<?php

include 'phpvms/core/classes/CodonWebService.class.php';
echo '<pre>';

$url = 'http://www.stopforumspam.com/api?email=nabeel@&f=xmlcdata';
$file = new CodonWebService();
$contents = $file->get($url);

var_dump($contents);


$response = simplexml_load_string($contents);
echo $contents;

On this page:

http://fivedev.net/test.php

Something is being returned - $contents is a 190 character string(of spaces apparently?)

Ah, they appeared to be having problems with their strict xml output, without that last variable it seems to be working fine. Got it working as expected now.

Thanks a lot

I’m going to post my code in the snippets forum just in case anyone else is having a spam problem

Ah, they appeared to be having problems with their strict xml output, without that last variable it seems to be working fine. Got it working as expected now.

Thanks a lot

I’m going to post my code in the snippets forum just in case anyone else is having a spam problem

Do they have json output?

I’d use that, easier than parsing XML, though in the end it would be the same. JSON would use less bandwidth:

$contents =- ...

$contents = json_decode($contents);
echo $contents->variable