Jump to content

Recommended Posts

Posted

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

  • Administrators
Posted

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);

  • Moderators
Posted

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?

  • Administrators
Posted

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

  • 1 month later...
Posted

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?

Posted

$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 :?

  • Administrators
Posted

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?)

Posted

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 :)

  • Administrators
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...