Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Created January 17, 2020 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicodeveloper/84f439a455b2e6189616ea594bf0c9a3 to your computer and use it in GitHub Desktop.
Save unicodeveloper/84f439a455b2e6189616ea594bf0c9a3 to your computer and use it in GitHub Desktop.
<?php
$payload = [
'event' => 'customer.subscribed',
'data' => [
'fullName': ‘olori baba’,
'email': ‘givethem@yahoo.com’ ,
'phoneNo': ‘08023975521’ ,
'homeAddress': ‘7, Marlian HQ’ ,
'landmark': ‘Near Mafo Studios’ ,
'gender': ‘non-binary’ ,
'area': 53 ,
'plan': ‘HARDWORKERSPLEETA’
]
];
$payloadJson = json_encode($payload);
$secret = env('EDEN_SPLEET_SECRET_KEY');
$signature = hash_hmac('sha512', $payloadJson, $secret);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://edenbackend-staging.herokuapp.com/api/spleet/hook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Spleet-Signature: {$signature}",
"accept: application/json"
],
CURLOPT_POSTFIELDS => $payloadJson
));
$response = curl_exec($curl);
$err = curl_error($curl);
if($err){
// there was an error contacting the API
return response()->json([
'status' => false,
'response' => $err,
], 500);
}
$tranx = json_decode($response, true);
return response()->json([
'status' => true,
'response' => $tranx
], 200);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment