Registering New Advocates via API
Learn how to register new advocates in your referral program using the Genius Referrals RESTful API. Registering new advocates on the Genius Referrals platform is straightforward and efficient. Below, we will guide you through the process effectively.
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71bn8038e6"; // Your API Token, you can get your token here https://app.geniusreferrals.com/en/settings/api-access
$accountSlug = 'sandbox';
$client = new GeniusReferralsLib\GeniusReferralsClient($contentType, $xAuthToken);
$advocates = $client->getAdvocates();
// Preparing data needed to sent on the request
$advocate = new \GeniusReferralsLib\Models\Advocate();
$advocate->name = 'John';
$advocate->lastname = 'Doe';
$advocate->email = 'john.doe@example.com';
$advocate->payoutThreshold = 1;
$advocate->canRefer = 1;
// New advocate successfully created
$newAdvocate = $advocates->postAdvocate($accountSlug, new \GeniusReferralsLib\Models\AdvocateForm($advocate));
// Adding the currency to the advocate
$advocatePatchForm = new \GeniusReferralsLib\Models\AdvocatePatchForm();
$advocatePatchForm->currencyCode = 'USD';
// Advocate currency successfully added to the advocate
$updatedAdvocate = $advocates->patchAdvocate($accountSlug, $newAdvocate->token, $advocatePatchForm);