Skip to main contentSkip to footer

How to let the Opencart APIs work for all IP addresses?

Rupak Nepali
Share:
How to let the Opencart APIs work for all IP addresses?

Opencart checks the IP address to allow the API calls, but sometimes you need to let all IP addresses do the API calls, for example, while testing the API. To allow all IP addresses to comment following the line of code at catalog/controller/api/account/login.php

//$json[‘error’] = sprintf($this->language->get(‘error_ip’), $this->request->server[‘REMOTE_ADDR’]);

if ($api_info) {
	// Check if IP is allowed
	$ip_data = [];

	$results = $this->model_account_api->getIps($api_info['api_id']);

	foreach ($results as $result) {
		$ip_data[] = trim($result['ip']);
	}

	if (!in_array($this->request->server['REMOTE_ADDR'], $ip_data)) {
		//$json['error'] = sprintf($this->language->get('error_ip'), $this->request->server['REMOTE_ADDR']);
	}
} else {
	$json['error'] = $this->language->get('error_key');
}

To learn more about Opencart API following posts help more:

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment