ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

sape_common_api.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class sape_common_api_1_0_0{
27
38 var $Client = false;
39 var $SapeUtilities = false;
40 var $Security = false;
41
56 function __construct()
57 {
58 try
59 {
60 $this->SapeUtilities = get_package( 'sape::sape_utilities' , 'last' , __FILE__ );
61 $this->Security = get_package( 'security' , 'last' , __FILE__ );
62 }
63 catch( Exception $e )
64 {
65 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
66 }
67 }
68
83 function connect()
84 {
85 try
86 {
87 $this->Client = get_package_object( 'xml::xml_rpc' , 'last' , __FILE__ );
88
89 $this->Client = $this->Client->get_xml_rpc_client( 'api.sape.ru' , '/xmlrpc/' );
90 }
91 catch( Exception $e )
92 {
93 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
94 }
95 }
96
119 function login( $Login , $PasswordHash )
120 {
121 try
122 {
123 $Login = $this->Security->get( $Login , 'string' );
124 $PasswordHash = $this->Security->get( $PasswordHash , 'string' );
125
126 $Parameters = array(
127 new xmlrpcval( $Login , 'string' ) , new xmlrpcval( $PasswordHash , 'string' ) ,
128 new xmlrpcval( true , 'boolean' )
129 );
130
131 $Response = $this->SapeUtilities->call_method(
132 $this->Client , 'sape.login' , $Parameters , 'Can\'t login to Sape'
133 );
134
135 $Cookies = $Response->cookies();
136
137 $this->Client->setcookie( 'SAPE' , $Cookies[ 'SAPE' ][ 'value' ] , $Cookies[ 'SAPE' ][ 'path' ] );
138 }
139 catch( Exception $e )
140 {
141 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
142 }
143 }
144 }
145
146 ?>