/*
* On your action method just do something like this
*/
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
//preparing the data to be sent on the request
$arrAdvocate = array(
'advocate' => array(
"name" => "Jonh",
"lastname" => "Smith",
"email" => "jonh@email.com",
"payout_threshold" => 20
)
);
$objResponse = $objGeniusReferralsAPIClient->postAdvocate('genius-referrals', $arrAdvocate);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
// advocate successfully created
if($intResponseCode == 201){
//getting the advocate token from the Location header
$arrLocation = $objResponse->getHeader('Location')->raw();
$strLocation = $arrLocation[0];
$arrParts = explode('/', $strLocation);
$strAdvocateToken = end($arrParts);
//Updating the advocate currency
$arrParams = array('currency_code' => 'USD');
$objResponse = $objGeniusReferralsAPIClient->patchAdvocate('genius-referrals', $strAdvocateToken, $arrParams);
$intResponseCode1 = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode1 == 204){
//currency successfully updated
// TODO: Save the reference between the new advocate and the customer on your local database.
// Use the $strAdvocateToken as a reference so that you can later use the method getAdvocate(...)
// to retrive the advocate data.
}
else{
// handle errors
}
}
else{
// handle errors
}
/*
* On your action method just do something like this
*/
//the advocate token
$strGRAdvocateToken = 'cc6bdb82850654d89bebada2b52e8028922b098c1d3';
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
$strResponse = $objGeniusReferralsAPIClient->getAdvocatesShareLinks('genius-referrals', $strGRAdovocateToken);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 200){
$objResponse = json_decode($strResponse);
}
else{
// handle errors
}
/*
* On your action method just do something like this
*/
$strGRAdvocateReferrerToken = $_GET['gr_at'];
$strGRCampaignSlug = $_GET['gr_cs'];
$strGRReferralOriginSlug = $_GET['gr_ro'];
$_SESSION['strGRAdvocateReferrerToken'] = $strGRAdvocateReferrerToken;
$_SESSION['strGRCampaignSlug'] = $strGRCampaignSlug;
$_SESSION['strGRReferralOriginSlug'] = $strGRReferralOriginSlug;
/*
* On your action method just do something like this
*/
//loading parameter from session
$strGRAdvocateReferrerToken = $_SESSION['strGRAdvocateReferrerToken'];
$strGRCampaignSlug = $_SESSION['strGRCampaignSlug'];
$strGRReferralOriginSlug = $_SESSION['strGRReferralOriginSlug'];
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
$arrParams = array(
'referral' => array(
'referred_advocate_token' => $strGRNewAdovocateToken, //the one create when the advocate was registered.
'referral_origin_slug' => $strGRReferralOriginSlug,
'campaign_slug' => $strGRCampaignSlug,
'http_referer' => $_SERVER['HTTP_REFERER']
)
);
$objGeniusReferralsAPIClient->postReferral('genius-referrals', $strGRAdvocateReferrerToken, $arrParams);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 201){
//if susccessfully created move on
}
else{
//handle errors
}
/*
* On your action method just do something like this
*/
//the advocate token of the customer that has place the payment
$strGRAdvocateToken = 'cc6bdb82850654d89bebada2b52e80289b098c1d3';
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
//preparing the data to be sent on the request
$arrParams = array(
'bonus' => array(
'advocate_token' => $strGRAdvocateToken, //the advocate who made the payment
'reference' => rand(1000000, 9999999), //A reference number, could be the payment id
'amount_of_payments' => 1,
'payment_amount' => 100 //the payment amount placed by the referred advocate
)
);
//trying to give a bonus to the advocate's referrer
$strResponse = $objGeniusReferralsAPIClient->postBonuses('genius-referrals', $arrParams);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 201){
// bonus given to the advocate's referrer
}
else{
// there is not need to give a bonus to the advocate's referrer
}
/*
* On your action method just do something like this
*/
//the advocate token of the customer that wants to add a paypal account
$strGRAdvocateToken = '44ae47f4eda382a8f5830b78fedb7cf1de88981b0';
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
//preparing the data to be sent on the request
$arrParams = array(
'advocate_payment_method' => array(
'username' => 'john@mail.com',
'description' => 'Personal Paypal account',
'is_active' => true
)
);
//trying to create a new paypal account for the advocate
$strResponse = $objGeniusReferralsAPIClient->postAdvocatePaymentMethod('genius-referrals', $strGRAdovocateToken, $arrParams);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 201){
// Paypal account successfully created
}
else{
// handle errors
}
/*
* On your action method just do something like this
*/
//the advocate token of the customer that wants to redeem his bonuses
$strGRAdvocateToken = '44ae47f4eda382a8f5830b78fedb7cf1de88981b0';
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
//preparing the data to be sent on the request
$arrParams = array(
'redemption_request' => array(
'advocate_token' => $strGRAdovocateToken,
'request_status_slug' => 'requested',
'request_action_slug' => 'credit',
'currency_code' => 'USD',
'amount' => 50,
'description' => 'Redeeming as credit'
)
);
//trying to create a new redemption request for the advocate
$strResponse = $objGeniusReferralsAPIClient->postRedemptionRequest('genius-referrals', $arrParams);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 201){
// Redemption request successfully created
}
else{
// handle errors
}
/*
* On your action method just do something like this
*/
// Create a new GRPHPAPIClient object
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
$strResponse = $objGeniusReferralsAPIClient->getRedemptionRequests('genius-referrals', 1, 10, 'email::john@mail.com');
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 200){
// request successfully processed
$objResponse = json_decode($strResponse);
//TODO: display data to the user
}
else{
// handle errors
}