Created
January 17, 2020 10:29
-
-
Save unicodeveloper/84f439a455b2e6189616ea594bf0c9a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$payload = [ | |
'event' => 'customer.subscribed', | |
'data' => [ | |
'fullName': ‘olori baba’, | |
'email': ‘[email protected]’ , | |
'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