| Line 7... |
Line 7... |
| 7 |
*/
|
7 |
*/
|
| 8 |
class Api extends AppModel {
|
8 |
class Api extends AppModel {
|
| 9 |
var $useTable = false;
|
9 |
var $useTable = false;
|
| 10 |
|
10 |
|
| 11 |
public function getDeals($userId=2,$page=1) {
|
11 |
public function getDeals($userId=2,$page=1) {
|
| - |
|
12 |
$apihost = Configure::read('apihost');
|
| 12 |
$url = "http://api.profittill.com/store_products/index/$userId/page:$page";
|
13 |
$url = $apihost."store_products/index/$userId/page:$page";
|
| 13 |
$params = array('client_id'=>$this->instagramconfig['client_id'],'client_secret'=>$this->instagramconfig['client_secret'],'grant_type'=>$this->instagramconfig['grant_type'],'redirect_uri'=>$this->instagramconfig['redirect_uri']);
|
14 |
// $params = array('client_id'=>$this->instagramconfig['client_id'],'client_secret'=>$this->instagramconfig['client_secret'],'grant_type'=>$this->instagramconfig['grant_type'],'redirect_uri'=>$this->instagramconfig['redirect_uri']);
|
| 14 |
return $this->make_request($url,null);
|
15 |
return $this->make_request($url,null);
|
| 15 |
}
|
16 |
}
|
| 16 |
|
17 |
|
| - |
|
18 |
public function getDealsByCategory($userId=2,$categoryId=1,$page=1) {
|
| - |
|
19 |
$apihost = Configure::read('apihost');
|
| - |
|
20 |
$url = $apihost."store_products/bycategory/$userId/page:$page";
|
| - |
|
21 |
// $params = array('client_id'=>$this->instagramconfig['client_id'],'client_secret'=>$this->instagramconfig['client_secret'],'grant_type'=>$this->instagramconfig['grant_type'],'redirect_uri'=>$this->instagramconfig['redirect_uri']);
|
| - |
|
22 |
return $this->make_request($url,null);
|
| - |
|
23 |
}
|
| - |
|
24 |
|
| - |
|
25 |
public function getCategoryDeals($userId=2,$page=1) {
|
| - |
|
26 |
$apihost = Configure::read('apihost');
|
| - |
|
27 |
$url = $apihost."store_products/bycategory/$userId/page:$page";
|
| - |
|
28 |
// $params = array('client_id'=>$this->instagramconfig['client_id'],'client_secret'=>$this->instagramconfig['client_secret'],'grant_type'=>$this->instagramconfig['grant_type'],'redirect_uri'=>$this->instagramconfig['redirect_uri']);
|
| - |
|
29 |
return $this->make_request($url,null);
|
| - |
|
30 |
}
|
| - |
|
31 |
|
| 17 |
public function make_request($url,$fields,$format='json'){
|
32 |
public function make_request($url,$fields,$format='json'){
|
| 18 |
$fields_string = '';
|
33 |
$fields_string = '';
|
| 19 |
if(!empty($fields)){
|
34 |
if(!empty($fields)){
|
| 20 |
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
35 |
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
| 21 |
rtrim($fields_string, '&');
|
36 |
rtrim($fields_string, '&');
|