API wrap around
-
Hi to all, considering that my software has an InstallId that needs to get paired with the LicenseId and that I want to avoid to hard code the consumer keys, I made the following work around php that calls the rest API and does the extra job.
As I am not a php expert, the question is, is it ok to make a call inside a call, or it could be a potentially server overloading problem?
By the way, congrats for this excellent solution.
P.D. I echo the results because I treat them as an INI file.
Kim
—————
<?php
if(isset($_GET[“id”])) {
$iguid = $_GET[“id”];
$ch = curl_init();curl_setopt_array($ch, array(
CURLOPT_URL => “{host}/wp-json/lmfwc/v2/licenses/”.$iguid.”?consumer_key={consumer_key}&consumer_secret={consumer_secret}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “GET”,
));$response = curl_exec($ch);
$err = curl_error($ch);curl_close($ch);
if ($err) {
echo “Error #:” . $err;
} else {$json = json_decode($response);
if ( $json->success == true) {echo “Key=” . $json->data->licenseKey . “\n”;
echo “Order=” . $json->data->orderId . “\n”;
echo “Version=” . $json->data->productId . “\n”;
echo “Status=” . $json->data->status . “\n”;
echo “Expires=” . $json->data->expiresAt . “\n”;}
// extra job here
}
}
?>
- The topic ‘API wrap around’ is closed to new replies.