Configure the actions on Freemius dashboard and put the url to this script. And you done it :-)
Created
February 21, 2018 13:28
-
-
Save Mte90/40ad4d9118ae599d90cfc4151f74b321 to your computer and use it in GitHub Desktop.
Freemius integration for OpenSupports
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 | |
echo "Parsing Freemius Webhook"; | |
// Get Freemius data | |
$json = file_get_contents('php://input'); | |
$data = json_decode($json, true); | |
if( isset($data['objects']['user']) ) { | |
// Let's call our opensupports instance | |
$name = $data['objects']['user']['first'] . ' ' . $data['objects']['user']['last']; | |
$password = 'dacambiare'; | |
// Post request | |
$service_url = 'https://syourdomain/api/user/signup'; | |
$curl = curl_init($service_url); | |
$curl_post_data = array( | |
'name' => $name, | |
'email' => $data['objects']['user']['email'], | |
'password' => 'dacambiare', | |
); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_POST, true); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); | |
$curl_response = curl_exec($curl); | |
if ($curl_response === false) { | |
$info = curl_getinfo($curl); | |
curl_close($curl); | |
error_log(print_r($curl_response,true)); | |
} | |
curl_close($curl); | |
$decoded = json_decode($curl_response); | |
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') { | |
error_log(print_r('error occured: ' . $decoded->response->errormessage,true)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment