SOAP Example : API

 

SOAP PHP Class Example

The following example is for SOAP Exchange with PHP

<?php

foreach (get_loaded_extensions() as $ext){
    if (
$ext=="soap")
        
$nativesoap=true;
}

if (
$nativesoap==true)
    
define('XOOPS_SOAP_LIB''PHPSOAP');
    
if (!
defined('XORTIFY_API_LOCAL'))
    
define('XORTIFY_API_LOCAL''http://xortify.chronolabs.coop/soap/');
    
if (!
defined('XORTIFY_API_URI'))
    
define('XORTIFY_API_URI''http://xortify.chronolabs.coop/soap/');    

class 
SOAPXortifyExchange {

    var 
$soap_client;
    var 
$soap_xoops_username 'user';
    var 
$soap_xoops_password 'pass';
    var 
$refresh 600;
    
    function 
SOAPXortifyExchange () {            
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$this->soap_client = new soapclient(NULL, array('location' => XORTIFY_API_LOCAL'uri' => XORTIFY_API_URI));
            break;
        }
    }
    
    function 
sendBan($comment$category_id 2$ip=false) {

        
$ipData getIPData($ip);
        
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('ban',
                 array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"bans"         =>     array(    0     =>     array_merge(
                                                                        
$ipData
                                                                        array(
'category_id' => $category_id)
                                                                        )
                                            ),
                            
"comments"     =>     array(    0    =>    array(    'uname'        =>        $this->soap_xoops_username
                                                                    
"comment"     =>         $comment
                                                            
)
                                             ) 
                    ));
            break;
        }
            
        return 
$result;    
    }

    function 
checkBans($ipdata) {
        
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('banned',
                 array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"ipdata"     =>     $ipdata)
                    ));
            break;
        }
            
        return 
$result;    
    }
    
    function 
checkUnbans($ipdata) {
        
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('unbanned',
                 array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"ipdata"     =>     $ipdata)
                    ));
            break;
        }
            
        return 
$result;    
    }
    
    function 
checkSFSBans($ipdata) {
        
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('checksfsbans',
                 array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"ipdata"     =>     array_merge($ipdata, array('category_id' => $category_id))
                    ));
            break;
        }
            
        return 
$result;    
    }

    function 
checkPHPBans($ipdata) {
        
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('checkphpbans',
                 array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"ipdata"     =>     $ipdata
                    
));
            break;
        }
            
        return 
$result;    
    }
        
    function 
retrieveBans() {
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('bans', array("username"=> $this->soap_xoops_username"password"=> $this->soap_xoops_password,  "records"=> $this->refresh));
            break;
        }
        return 
$result;
    }

    function 
retrieveUnbans() {
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('unbans', array("username"=> $this->soap_xoops_username"password"=> $this->soap_xoops_password,  "records"=> $this->refresh));
            break;
        }
        return 
$result;
    }

    function 
sendSpider($spider) {

        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('spider',
                array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"spider"    =>     $spider    ) );
            break;
        }
            
        return 
$result;    
    }
    
    function 
sendStatistic($statistic) {

        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('spiderstat',
                array(      
"username"    =>     $this->soap_xoops_username
                            
"password"    =>     $this->soap_xoops_password
                            
"statistic"    =>     $statistic    ) );
            break;
        }
            
        return 
$result;    
    }
    
    function 
getSpiders() {
            
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('spiders',
                        array(  
"username"    =>     $this->soap_xoops_username
                                
"password"    =>     $this->soap_xoops_password));
            break;
        }
            
        return 
$result['robots'];        
    }
    
    function 
getSEOLinks() {
            
        switch (
XOOPS_SOAP_LIB){
        case 
"PHPSOAP":
            
$result $this->soap_client->__soapCall('seolinks',
                        array(  
"username"    =>     $this->soap_xoops_username
                                
"password"    =>     $this->soap_xoops_password));
            break;
        }
            
        return 
$result['seolinks'];        
    }

?>
Written by: System Overlord 2011/4/21