-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi-test.php
43 lines (36 loc) · 1.03 KB
/
api-test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();
$API_username = ''; // Insert your API Username
$API_Key = ''; // Insert your API Key
$result = array();
$method = 'customapi';
$args = '';
if ( !empty($_GET['list']) ) {
$method .= ( $_GET['list'] == 'block' ) ? '.blocklist' : '.pagelist';
$args = !empty($_GET['sortby']) ? $_GET['sortby'] : 'created';
}
elseif ( !empty($_GET['content']) ) {
$method .= ( $_GET['content'] == 'block' ) ? '.blockcontent' : '.pagecontent';
$args = !empty($_GET['id']) ? (int)$_GET['id'] : 0;
}
else {
$method .= '.pagelist';
$args = 'created';
}
try {
$soap = new SoapClient(Mage::getBaseUrl().'/api/soap/?wsdl');
$session = $soap->login($API_username, $API_Key);
$result = $soap->call($session, $method, array($args));
$soap->endSession($session);
} catch(Exception $e) {
$result = array(
'messages' => array(
'code' => 401,
'message' => $e->getMessage()
)
);
}
echo '<pre>';
print_r($result);