Jump to content
Sign in to follow this  

Cannot get cURL request to work hooks -> Zapier

Recommended Posts

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?

Share this post

Link to post
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.

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.

Sign in to follow this  

  • Similar Content

    • By Mas-J
      Dear All,
      I want to show the Next Invoice Date under Next Due Date when admin access Page Client Details on Product/Services Tab.
      But, I've no idea how to show it, I just know to get the Next Invoice Date value related from tblhosting
      Anyone can help me to show it ? Thank you.
      <?php use WHMCS\Database\Capsule; add_hook('AdminClientServicesTabFields', 1, function($vars) { $PID = $vars['id']; $nextinvoicedate = Capsule::table('tblhosting')->where('id', $PID)->pluck('nextinvoicedate'); $result = array(); $result['nextinvoicedate'] = $nextinvoicedate; return $result });

    • By ramf
      Can someone please help me with this hook? 
      It was created by @brian!  and appeared here- but sadly he can't help me. 
      Since I'm selling mostly one time products - I have lots of inactive clients and I want to be able to find them easily without the hassle of  changing the search toggle.
      There it this feature request  that was opened 2 years ago to make the hide inactive clients optional (please vote) - but until this happens I have no choice but to use this hook:
      <?php add_hook('AdminAreaHeadOutput', 1, function($vars) { if ($vars['filename'] == 'clients' OR in_array($vars['pagetitle'], array(AdminLang::trans('services.title'), AdminLang::trans('services.listaddons'), AdminLang::trans('services.listdomains')))) { $autoPost = <<<HTML if ($('input#checkboxShowHidden').is(':checked')) { $('body').addClass('hidden'); $('#checkboxShowHidden').click(); } HTML; } return <<<HTML <script> $(document).on('ready', function() { if ($('input#intelliSearchHideInactiveSwitch').is(':checked')) { $('#intelliSearchHideInactiveSwitch').click(); } {$autoPost} }) </script> HTML; }); The problem with this one is that the search bar is always opened with this error - in every page loading:
      So even If i'm not clicking on the search field - the search bar is opened with this message.
      Can someone help me figure out what should be changed in this hook file so it will not open the search bar automatically - but when we do search we will see the inactive clients alongside the active onse?

    • By Eldremor
      Hello, is there anyway via hook or modifying the php to add images before X configurable option name?
    • By Nelson Neoh
      Hi all,
      I wish to perform some registrar API activities in the registrar hooks, but as the hook's vars or params didn't provide credential details, I tried to get direct from DB Capsule and unfortunately noticed the data stored in encrypted format...
      Any suggestions to over come this?
      Best Regards,
    • By Trescpress
      I am working on a custom hook and I find that just by adding an input field of type Tel, the country code is added by WHMCS.
      I am basically showing a modal from my hook if a condition is met.
      Now I am testing the example code on the IntlTelInput plugin website (https://intl-tel-input.com/node_modules/intl-tel-input/examples/gen/default-country-ip.html)
      $(document).ready(function(){ var input = document.querySelector("#phone"); window.intlTelInput(input, { initialCountry: "auto", geoIpLookup: function(callback) { $.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) { var countryCode = (resp && resp.country) ? resp.country : "us"; callback(countryCode); }); }, }); }); <input type="tel" id="phone">  
      But that's returning an error:
      I basically want to sow the local country code in the form. is there a way to achieve this? bearing in mind that I am not in the tpl file, just echoing a modal from my hook.
  • 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