Subversion Repositories SmartDukaan

Rev

Rev 13579 | Rev 13659 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13579 Rev 13633
Line 34... Line 34...
34
				Configure::load('dev');
34
				Configure::load('dev');
35
				break;
35
				break;
36
			default:
36
			default:
37
			case 'www.profittill.com':
37
			case 'www.profittill.com':
38
			case 'profittill.com':
38
			case 'profittill.com':
-
 
39
			case 'api.profittill.com':
39
				Configure::load('live');
40
				Configure::load('live');
40
				break;
41
				break;
41
		}
42
		}
42
		$facebookConfig = Configure::read("Facebook");		
43
		$facebookConfig = Configure::read("Facebook");		
43
		$categories = Configure::read('Categories');
44
		$categories = Configure::read('Categories');
Line 74... Line 75...
74
 
75
 
75
    function beforeRender() {    	
76
    function beforeRender() {    	
76
        $this->set('base_url', 'http://' . $_SERVER['SERVER_NAME'] . Router::url('/'));
77
        $this->set('base_url', 'http://' . $_SERVER['SERVER_NAME'] . Router::url('/'));
77
        // $this->set('base_url', 'http://api.profittill.com/');
78
        // $this->set('base_url', 'http://api.profittill.com/');
78
    }
79
    }
79
}
-
 
80
 
80
 
81
if (!function_exists('getallheaders')) 
-
 
82
{ 
-
 
83
    function getallheaders() 
81
	    function getallheaders() { 
84
    { 
-
 
85
           $headers = ''; 
82
		   $headers = ''; 
86
       foreach ($_SERVER as $name => $value) 
83
	       foreach ($_SERVER as $name => $value) 
87
       { 
84
	       { 
88
           if (substr($name, 0, 5) == 'HTTP_') 
85
		   if (substr($name, 0, 5) == 'HTTP_') 
89
           { 
86
		   { 
90
               $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
87
		       $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
91
           } 
88
		   } 
92
       } 
89
	       } 
93
       return $headers; 
90
	       return $headers; 
94
    } 
91
	    } 
-
 
92
 
-
 
93
	function make_request($url,$fields,$format='json'){
-
 
94
		$this->log($url,'pythonapi');
-
 
95
		$this->log($fields,'pythonapi');
-
 
96
		$fields_string = '';
-
 
97
		//open connection
-
 
98
		$ch = curl_init();
-
 
99
		//set the url, number of POST vars, POST data
-
 
100
		curl_setopt($ch,CURLOPT_URL, $url);
-
 
101
		curl_setopt($ch,CURLOPT_RETURNTRANSFER , true);
-
 
102
		if(!empty($fields)) {
-
 
103
			curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
-
 
104
			curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
-
 
105
			    'Content-Type: application/json',                                                                                
-
 
106
			    'Content-Length: ' . strlen($fields))                                                                       
-
 
107
			);   
-
 
108
		}
-
 
109
		//execute post
-
 
110
		$result = curl_exec($ch);
-
 
111
		//close connection
-
 
112
		curl_close($ch);
-
 
113
		switch($format){
-
 
114
			case 'json':
-
 
115
			$response = json_decode($result,1);
-
 
116
			break;
-
 
117
		}
-
 
118
		return $response;	
-
 
119
	}
95
}
120
}