Tag Archives: Webservice

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 = "http://www.example.com/developer/webservice/testservice/wsdl";
    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');