Archive | Webservice RSS feed for this section

Remote article randomizer for Search Engine Optimization

10 Nov

Search Engine always like new content in the website and also inbound link from other website. To meet this requirement we creates several satellite website(A article website for link building) and link it with our Sales website.

But it become annoying to populate content every day in satellite websites separately.

To make life easy! We can look little bit out of the box. We can create a repository website to store all article. All other site will send request to the repository website to fetch content, it can be randomly or latest first.

We can create this scenario in a convenient way by appRain Web-Service module.

Step 1: Create Web Service method
We have to create a web-service class in the system. We can do it in testservice.php(development/helper/api/) which is ready. Simply add the following method

  * @param FixedArray Must be an array
  * @return FixedArray Must be an array
  public function getContentByCode($options = Array()) {
       // We can filter content by Category 
       // or keyword as per need
       // Here we have fetch data from Information Set but 
       // we can do that from Model or Category Set as per need
       return App::InformationSet('content')
                    ->findAll("1 ORDER BY RAND() LIMIT {$options[3]}");

Once we have add this class then our web-service is ready and WSDL link will be like

Step 2: Create plug-in class
Now we will create a simple class to connect the repository. Simple we can add this class:

class appContentRamdomizer{
    //Singleton instance    
    private  $ar_proxy = null;
    public   $ws_url = "";
    public function __construct($url=null) {
        if(isset($url)) $this->ws_url = $url;
    public function getContentByCode($keyword=null) {
        $proxy = $this->getService();
        // In this method we are passing some param
        // to use when we fetch content 
        $content = $proxy->getContentByCode(array(
                                $keyword = 'keyword', 
                                $isRamdomize = true,
                                $limit = 1));
        return $content;

    private function getService(){   
            $this->ar_proxy = new soapclient($this->ws_url);
        return $this->ar_proxy;

Step 3: Fetch remote data
This is a simple step to fetch article form remote repository:

$appCR = new appContentRamdomizer();
$content = $appCR->getContentByCode('keyword');


PHP Webservice Class

4 Mar

There are lots of extension available to create PHP Web service Like Nusoap or WSDL helper. But it’s not too taught to create a web service if you understand WSDL definition, PHP reflection API and have a bit knowledge of to create and parse XML Document.

Here I have shared a PHP Web service class with some example of Client/Server implementation. That I developed to crate a plug-in for me.


– Parse a PHP Class and create WSDL definition
– Use SOAP for Client Server Communication
– Easy to integrate and develop in a very simple way.
– A Cryptography Class is integrated to handle JSON format data.


– PHP 5 or greater Version
– PHP DOM(DOMDocument) extension


– This class generate WSDL document for all common Data Types(String, Integer, Boolean, Float, Double). Complex data type (Class Objects) are in further development.


– Use JSON ( Cryptography Class added here) to pass complex data type like Array


Version 0.1.0
Download Link