Build your own Web Service with PHP and XML-RPC

This is an article discussion thread for discussing the SitePoint article, “Build your own Web Service with PHP and XML-RPC

Has anyone had any luck in getting this code to work?

I’ve been unable to display a list of articles. I get a consistent error of:
Warning: Variable passed to each() is not an array or object in /Library/WebServer/Documents/kd_xmlrpc/client.php on line 8

peterm

Make sure that $site and $location variables in client.php are set correctly. $site + $location should give you the path to your server.php script

I prefer using SOAP although RPC is sometimes usefull.

I had problem with Keith Deve library as I dowloaded it from here in that zip folder where you have everything all files needed for this tutorial, and it was showing an error on line 453 cannot reassign $this bla bla, but it is easily fixed if you go and download the latest version for Deve’s site. Otherwise great article :slight_smile:

Getting an error in fsockopen of kd_xmlrpc for connection when working in public_html of /home/user/

Do you have xml security also?

I try to use this library and this code, but, nothing happend, I have no error message, but i haven’t results… why ?

Regards,
Fabrice

Don’t forget your site may restrict xml access through apache - in this case you’ll need an .htaccess file in your server directory that says something like:

<Files *.php>
allow from all
SecFilterInheritance Off
</Files>

Also, to Fabrice, use the XMLRPC_debug_print() function to see what’s going on.

The example coding return following error
Fatal error: Cannot re-assign $this in C:\xampp\htdocs\kd_xmlrpc\kd_xmlrpc.php on line 454

The example coding return following error
Fatal error: Cannot re-assign $this in C:\xampp\htdocs\kd_xmlrpc\kd_xmlrpc.php on line 454

Me too…

Hello
to :Nava, lolo

To solve your error, just switch to php4
If you have xampp server (version < 1.7.0), you can switch using C:\xampp\php-switch.bat

Cheers,
Marius

I am using php 5.0 and it works for me after doing the followings:

1)Copy the kd_xmlrpc.php and the Client.php from the site instead of the zip one. The rest are ok.
2)Edit the following code on the Client.php according to your location:

$site = “localhost”; //if you are using localhost
$location = “/kd_xmlrpc/server.php”; //note the location of your files on the server

Thanks a lot for a wonderful easy to understand tutorial on web services.
I got the concept but when i was working on your example, i did not get the intended result. After banging my head for a few hours i found out the following error:
1- on page web_service_api.php on line 7,8 and 9 the function name should be in quotes like:
$xmlrpc_methods[‘news.getNewsList’] = ‘news_getNewsList’;

Regards,
sumaiya