Jump to content

Post vars to offsite script action hook


openmind

Recommended Posts

Now as I''m a ColdFusion programmer by trade, PHP is not my strong point ;)

 

But moving on...

 

What I would like to do is have a simple action hook that fires the whmcs vars to an offsite script. Theis script will then run my CF code.

 

So in pseudo code:

function create_forum_account($vars) {
   post vars to http://www.domain.com/myscript.cfm
}
add_hook("ClientAdd",1,"create_forum_account");

Can anyone provide the PHP script to simply post the vars to a location of my choosing please?

Link to comment
Share on other sites

Would something like this work?

function create_forum_account($vars) {
      //set POST variables
   $url = 'http://domain.com/myscript.cfm';

   //url-ify the data for the POST
   foreach($vars as $key=>$value) { $vars_string .= $key.'='.$value.'&'; }
       rtrim($vars_string,'&');
   }

   //open connection
   $ch = curl_init();

   //set the url, number of POST vars, POST data
   curl_setopt($ch,CURLOPT_URL,$url);
   curl_setopt($ch,CURLOPT_POST,count($vars));
   curl_setopt($ch,CURLOPT_POSTFIELDS,$vars_string);

   //execute post
   $result = curl_exec($ch);

   //close connection
   curl_close($ch);

add_hook("ClientAdd",1,"create_forum_account");

Note that I'm using the create_forum_account as an example, I would want this to work with any function, just post the vars as I can handle the incoming data with my script...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated