1

I have created custom api for customer module with help of this Link. I want to restrict the number of users to access this api.

Now how Can I restrict number of users are limited to access request/min.

Can you give Any suggestions/Idea on this?

Thanks in advance.

0

When the first request comes in you could store the current time and request number in session. The way you implement this API should have a session associated with it.

Here is some untested code to give you an idea:

$session = Mage::getSingleton('api/session');
$requestNumber = $session->getRequestNumber();
if(!isset($requestNumber)){
$session->setInvokeTime(now());
$session->setRequestNumber(1);
}else{
    $session->setRequestNumber($session->getRequestNumber() +1);
}
if($session->getRequestNumber() == 11){
    if(($session->getInvokeTime() -now())  < 60) {
        return;
    }else{
        $session->setInvokeTime(now());
        $session->setRequestNumber(1);
    }
}
  • ,thanks you. I will get back to you If i have any queries on this. – Magento007 Aug 25 '14 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.