Skip to content

Instantly share code, notes, and snippets.

@Mte90
Created February 21, 2018 13:28
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 Mte90/40ad4d9118ae599d90cfc4151f74b321 to your computer and use it in GitHub Desktop.
Save Mte90/40ad4d9118ae599d90cfc4151f74b321 to your computer and use it in GitHub Desktop.
Freemius integration for OpenSupports

Configure the actions on Freemius dashboard and put the url to this script. And you done it :-)

<?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