views:

21

answers:

1

Hi all,

I think that I am having a slow evening but I have a question regarding calling a URL as part of a controller call in a Zend Framework application.

I'm trying integrate an affiliate tracking application into my code, and the only way to register a commission is to call a url and pass the variables as either a POST or GET request, such as:

http://affilaite.myserver.com/sale.php?affiliate_id=1234&sale_amt=123.45

Now I want to call this on successful completion of the payment process, to update the affiliate software. I have a class that I use for other affiliate functions and I would like to be able to call a process() function to either POST the data or send it as a get request, e.g.

class CheckoutController extends Zend_Controller_Action{     
   ...       
   public function successAction(){

      //deals with response from payment provider first        

      //process the affiliate 
      $affliate = new Affiliate();
      $affiliate->process($affiliateId, $amount);

      ...
   }
}

Now I'm can't think at this moment how I can make another post or get request as the controller is already going through the response lifecycle dealing with the payment process response.

How can I initiate another request to a different server halfway through this cycle? I'm not sure it's even possible? Are there other ways that this can be achieved? There is a strong possibility that this function could be called many times during this function as it could be an array of affiliateids, rather than one.

Any help would be gratefully appreciated.

Thanks...

+1  A: 

Use the zend-framework http client: http://framework.zend.com/manual/en/zend.http.client.advanced.html

Bob Baddeley