Jump to content

Cannot get cURL request to work hooks -> Zapier


karlfrankeser

Recommended Posts

Hello,
I am new to this community!

I am setting up a hook that allows me to pass new client data to Zapier in order to update our Marketing automation software.

This is the code I have been testing now:

add_hook('ClientAdd', 1, function ($vars)
{
    $userid = $vars['userid'];
    $firstname = $vars['firstname'];
    $lastname = $vars['lastname'];
    $email = $vars['email'];
    $phone = $vars['phonenumber'];
    $city = $vars['city'];
    $country = $vars['country'];
    $postcode = $vars['postcode'];
    $company = $vars['companyname'];
    $state = $vars['state'];
    
    $params = '?userid='.$userid.'&firstname='.$firstname.'&lastname='.$lastname.'&email='.$email.'&phonenumber='.$phone.'&city='.$city.'&country='.$country.'&postcode='.$postcode.'&companyname='.$company.'&state='.$state.'&source=WHMCS';
    
    $url = 'https://hooks.zapier.com/hooks/catch/zzz/rrrr/'.$params;
    $options = array( 'CURLOPT_POST' => 0 );
    $response = curlCall($url,$postfields,$options);
    
    logActivity('logged addClient with params: ' . $params . 'following is the result: ' . $request, $userid);
});

I also tried to send this via file_get_contents but it does not seem to work, by composing the url together with real world values gotten from the LOG in the admin area the request works on Zapier's end, I suppose that the problem lies within WHMCS and the request. The Zapier request has been altered for privacy reasons.

 

Can anyone point me in the right direction?

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.

×
×
  • 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