Lead capture error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • livewire
    Senior Member
    • Nov 2016
    • 100

    Lead capture error

    Hi

    Im trying to capture leads from my website to the crm.. I followed the code give but it gives me an error

    Fatal error: Uncaught Exception: EspoClient: Unknown Error

    by code is as below

    require_once('includes/EspoApiClient.php');

    $client = new EspoApiClient('https://www.mywebsite.com/crm/');

    $apiKey = '78d5b5771e0e2eedae78a393aebfb193'; // specify your API key here

    $formData = [
    'firstName' => $_POST['name'],
    'phoneNumber' => $_POST['mobileno'],
    'emailAddress' => $_POST['email']
    ];

    $client->request('POST', 'LeadCapture/' . $apiKey, $formData);


    can someone tell me what might be the problem?




  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    I think you need to adjust your site url

    Code:
    <?php
    
    require_once('EspoApiClient.php');
    
    // update the url
    $client = new EspoApiClient('https://www.mywebsite.com/crm/api/v1/');
    
    $apiKey = '78d5b5771e0e2eedae78a393aebfb193'; // specify your API key here
    
    $formData = [
          'firstName' => $_POST['name'],
          'phoneNumber' => $_POST['mobileno'],
          'emailAddress' => $_POST['email']
    ];
    
    $client->request('POST', 'LeadCapture/' . $apiKey, $formData);
    Cheers
    Last edited by rabii; 01-01-2022, 10:30 PM.
    Rabii
    Web Dev

    Comment

    Working...