Hey there, fellow developer! Ready to supercharge your lead tracking with WhatConverts? Let's dive into building a slick API integration using the andrew501983/what-converts-php
package. This nifty tool will have you pulling lead data like a pro in no time.
Before we jump in, make sure you've got:
First things first, let's get that package installed. Fire up your terminal and run:
composer require andrew501983/what-converts-php
Easy peasy, right?
Now, let's set up those credentials and get our client ready to roll:
use WhatConverts\WhatConvertsClient; $client = new WhatConvertsClient('your-api-key', 'your-account-id');
Boom! You're connected and ready to go.
Let's start with the basics - fetching those juicy leads:
$leads = $client->getLeads();
Want details on a specific lead? No sweat:
$leadId = 123456; $leadDetails = $client->getLead($leadId);
Ready to level up? Let's filter, sort, and paginate like a boss:
$leads = $client->getLeads([ 'filter' => ['status' => 'new'], 'sort' => ['created_at' => 'desc'], 'page' => 1, 'per_page' => 50 ]);
Don't forget to catch those pesky errors:
try { $leads = $client->getLeads(); } catch (\Exception $e) { echo "Oops! " . $e->getMessage(); }
Let's put it all together and create a sweet dashboard widget:
function getRecentLeads($limit = 5) { $client = new WhatConvertsClient('your-api-key', 'your-account-id'); try { $leads = $client->getLeads([ 'sort' => ['created_at' => 'desc'], 'per_page' => $limit ]); return $leads; } catch (\Exception $e) { return "Error fetching leads: " . $e->getMessage(); } } // In your dashboard view $recentLeads = getRecentLeads(); foreach ($recentLeads as $lead) { echo "<p>{$lead['name']} - {$lead['phone']}</p>"; }
Remember, with great power comes great responsibility:
Running into issues? Here are some common hiccups:
And there you have it! You're now a WhatConverts API integration wizard. Remember, practice makes perfect, so keep experimenting and building awesome stuff.
Need more info? Check out the WhatConverts API docs and the package repository for all the nitty-gritty details.
Now go forth and convert those leads! 🚀