Location: PHPKode > scripts > Allegro script > allegro-script/auctionsManager.php
<?php 
require_once 'lib/nusoap.php';
require_once 'auction.php';
require_once 'auctionSold.php';
require_once 'conf.php';

class AuctionsManager{

	var $fileName;
	var $soap;
	var $sesja=array();
	var $closedAuctions;

//////////////////////////////Funkcja logowania///////////////////
function logowanie(nusoap_client $soap){
	$country = constant('COUNTRY');
	$params = array(
	 'sysvar' => 1, //which feature you are asking for, 1 is for AllegroWebApi, other possible options above
 	'country-id' => $country, //country code, 1 is for Poland, all country codes are available in doLogin method documentation
 	'webapi-key' => constant('WEB_KEY') //your webapi key
 	);
	$verkey = $soap->call('doQuerySysStatus',$params);
	$wersja = $verkey['ver-key'];
	$password=constant('PASS');
	/*
 if(function_exists('hash')){
# //hash used in PHP since version 5.1.3
 $password = hash('sha256',$password,true);
 }
 else {
 //in older version we should use mhash
 $password = mhash(MHASH_SHA256,$password);
 }
  
 //base64 for encoded binary password transfer
 $password = base64_encode( $password);
  */

	$msg = array
 	(
 	'user-login' => constant('LOGIN'),//"kuba9913",
 	'user-password' => $password,//"qwerty1",
 	'country-code' => $country,
 	'webapi-key' => constant('WEB_KEY'),
 	'local-version' => $wersja, 
 	);
  
	$response = $soap->call('doLogin', $msg);
 
 $err = $soap->getError();
    if ($err) {
        // Display the error
        echo '<p><b>Login Error: ' . $err . '</b></p>';
    } else {
        // Display the result       
        //echo 'You are logged in.';
    }
    
    //////cats 
    
  /*  	$data =array(
 		'country-id' => $country,
 		'local-version' => $wersja,
 		'webapi-key' => "bcffcf60d",
		);	
	$response = $soap->call('doGetCatsData', $data);
    print_r($response);
    
  
    $param = array (
    'country-code' => 228,
    'local-version' => 1,
    'webapi-key' => "bcffcf60d"
    );
    $result = $soap -> call('doGetSellFormFields', $param);
     
    echo "<pre>";
    print_r($result);
   echo "</pre>";
   */  
    
    return $response;
}


//////////////////////////Funkcja utworz wszystkie aukcje/////////
function loadFile($text){
	
$handle = fopen($text, "r");
$row = 0;
$auctions=new Auction($this->soap,$this->sesja);
while (($data = fgetcsv($handle, 10000, "	")) !== FALSE) {
	
   if($row>0){   

   			$soap = new nusoap_client('http://webapi.allegro.pl/uploader.php?wsdl',wsdl );
			$soap->soap_defencoding = 'UTF-8';
			$soap->decode_utf8 = false;

	$auctions->sell($data,$soap);
	unset($data);

   }
   $row++; 
}
unset($auctions);
fclose($handle);	
return $row;
}

/////////////////////////////Funkcja sprawdza czy sa wygrane aukcje//////////
function checkSold(){

	$param = array (
   	'session-handle' => $this->sesja['session-handle-part'],
    'account-type' => 'sold',
    'offset' => 0,
   	'tems-array' => ''
    );
	
	 $items=$this->soap->call('doMyAccount2',$param);	
	 $i=0; 
	 foreach($items as $item){									//return null if not sold or returned allready
	 	$closedAuctions = new AuctionSold($this->soap,$this->sesja,$item["my-account-array"]); 
	 }	 
}
function checkNotSold(){
	 
	$this->soap = new nusoap_client('http://webapi.allegro.pl/uploader.php?wsdl',wsdl );
	$this->soap->soap_defencoding = 'UTF-8';
	$this->soap->decode_utf8 = false;

	$err = $this->soap->getError();
				if ($err) {
    				return false;
				}else $this->sesja = $this->logowanie($this->soap); 

	$param = array (
   	'session-handle' => $this->sesja['session-handle-part'],
    'account-type' => 'not_sold',
    'offset' => 0,
   	'tems-array' => ''
    );
    
     $items=$this->soap->call('doMyAccount2',$param);	
	 $i=0; 
	 foreach($items as $item){									//return null if not sold or returned allready
	 	$closedAuctions = new AuctionSold($this->soap,$this->sesja,$item["my-account-array"]); 
	 }	 
	 
	 unset($this->soap);
	 unset($this->sesja);
	 
}
		
//////////////////////////////////Konstruktor///////////////////		
function AuctionsManager(){
	
	
	
	$this->soap = new nusoap_client('http://webapi.allegro.pl/uploader.php?wsdl',wsdl );
	$this->soap->soap_defencoding = 'UTF-8';
	$this->soap->decode_utf8 = false;

	$err = $this->soap->getError();
	if ($err) {
    	// Display the error
    	//echo '<p><b>Allegro Constructor error: ' . $err . '</b></p>';
    	return false;
    	// At this point, you know the call that follows will fail
	}else $this->sesja = $this->logowanie($this->soap); 


}


} /////////////////////////////end of the class//////////////////


?>
Return current item: Allegro script