Subversion Repositories SmartDukaan

Rev

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

Rev 17682 Rev 17804
Line 281... Line 281...
281
			$response = json_decode($result,1);
281
			$response = json_decode($result,1);
282
			break;
282
			break;
283
		}
283
		}
284
		return $response;	
284
		return $response;	
285
	}
285
	}
286
 
286
	
-
 
287
	function post_cartinfo_request($url,$fields,$format='json'){
-
 
288
		$this->log("[url] $url",'api');
-
 
289
		//$this->log("[fields] ".print_r($fields,1),'api');
-
 
290
		$fields_string = '';
-
 
291
		//open connection
-
 
292
		$ch = curl_init();
-
 
293
		//execute post
-
 
294
		foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
-
 
295
		rtrim($fields_string, '&');
-
 
296
		//set the url, number of POST vars, POST data
-
 
297
		curl_setopt($ch,CURLOPT_URL, $url);
-
 
298
		curl_setopt($ch,CURLOPT_POST, count($fields));
-
 
299
		curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
-
 
300
		curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
-
 
301
		curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
-
 
302
		$result = curl_exec($ch);
-
 
303
		//close connection
-
 
304
		curl_close($ch);
-
 
305
		switch($format){
-
 
306
			case 'json':
-
 
307
			$response = json_decode($result,1);
-
 
308
			break;
-
 
309
		}
-
 
310
		return $response;	
-
 
311
	}
-
 
312
	
287
	function post_request($url,$fields,$format='json'){
313
	function post_request($url,$fields,$format='json'){
288
		$this->log("[url] $url",'api');
314
		$this->log("[url] $url",'api');
289
		$this->log("[fields] ".print_r($fields,1),'api');
315
		$this->log("[fields] ".print_r($fields,1),'api');
290
		$fields_string = '';
316
		$fields_string = '';
291
		//open connection
317
		//open connection