-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.php
61 lines (57 loc) · 1.72 KB
/
process.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Definir Directorias
*/
$RootDir = '';
$LibsDir = $RootDir.'Libs';
/**
* Carregar Bibliotecas
*/
//require_once $LibsDir.'/Underscore.php'; //Tratamento de Arrays e Objectos [OPCIONAL]
require_once 'httpful_autoload.php'; //Pedidos API REST [NECESSARIA]
require_once $LibsDir.'/ServerAPI.php'; //
/**
* Instanciar Classe Principal para ligação à API CUSTO JUSTO
*/
$service = new CustojustoAPI();
$url = '/'.$_POST['url'];
$objecto = $_POST['url'];
$action = $_POST['action'];
/**
* Evocar funçoes específicas de operação
*/
switch ($action){
case 'get-dados' :
$resposta = $service->getURL($url,$objecto);
break;
case 'add-anuncio' : //$url = '/entries/12495697';
$anuncio = $_POST['objecto_anuncio'];
$resposta = $service->addURL($url,'POST',$anuncio);
break;
case 'alterar-anuncio' :
$url = '/'.$_POST['url'];
$resposta = $service->addURL($url,'POST',$anuncio);
break;
case 'ver-anuncio' :
$url = '/'.$_POST['url'];
$resposta = $service->getURL($url,$objecto='nada');
break;
case 'eliminar-anuncio' :
$url = '/'.$_POST['url'];
$resposta = $service->delURL($url);
break;
case 'adicionar-imagem' :
$url = '/'.$_POST['url'];
$files = array('file' => 'img/carro.jpg');
$resposta = $service->postMimeURL($url,$files);
break;
default :
$resposta = $service->getURL($url,$objecto);
break;
}
/**
* Devolver dados em JSON
*/
var_dump($resposta);
//echo get_object_vars($resposta['dados']);
echo json_encode($resposta->message);