Hi All,
With Mack pointing me in the right direction to get JSON data into an Opus publication using PHP to convert the JSON to a String and then using Post Web Data in Opus Pro assigning that to Opus variables and use as needed via OpusScript.
The reason I needed to do it was that I am implementing SendOwl to manage serial numbers, their auto generation, deployment of the software, customer management, etc and they provide a look up to verify the serial number is valid for the order and returns a JON return. This is useful to deter software piracy and automate the processing and deployment of software to customers.
In a couple of months I'll try and post back my experience, but for me I wanted a hands off solution that would manage this part of my software licenses with little interaction from me.
SendOwl:
https://www.sendowl.com/SendOwl Code Verification via PHP:
https://github.com/SendOwl/community-codePHP for Opus Pro to Send and Read the JSON, see code snipped below for PHP. It is important to keep this on your own server to protect your secret key and I recommend HTTPS too, as I do for any data transmitted over the web.
Code:
<?php
// Setup variables
$key = 'abc'; // TODO: replace with your own unqiue key with SendOwl (not to be confused with the software key
$secret = 'def'; // TODO: replace with your own this is a unqiue secret key with SendOwl
// $productId = '42701623423'; // TODO: replace with your own each software sold on send owl has it's own unique code
// $licenseKeyToCheck = '8BC3-57CD-13AB-3C53'; // TODO: this is the serial number that the user enters into the opus publication and is posted to SendOwl to verify it is a legit key associated with the productId.
$productId = $_POST['opusPostProductID'];
$licenseKeyToCheck = $_POST['opusPostSoftwareKey'];
// both productId and licenseKeyToCheck need to be passed to this PHP code, i recommend gathering some of this data into your own sql data base and capture some further aux information from the customer.
$url = 'https://' . $key . ':' . $secret . '@www.sendowl.com/api/v1/products/' . $productId . '/licenses/check_valid?key=' . $licenseKeyToCheck;
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Accept: application/json' ) ); // for json use: 'Accept: application/json' or xml use: 'Accept: text/xml'
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
// WARNING REMOVE THIS CODE WHEN LIVE
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// remove this line of code as it ignores SSL and the whole point of it, open to a potential MITM (man-in-the-middle) attacks if kept
// http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
// http://stackoverflow.com/questions/6400300/https-and-ssl3-get-server-certificatecertificate-verify-failed-ca-is-ok/10566962
$output = curl_exec( $ch );
curl_close($ch);
// convert JSON string to array
$jsonArray = json_decode($output, true);
// print_r($jsonArray ); // dump all data of the array for testing
// below could be just one line of code, but broke out so easier to read
echo "ID=".$jsonArray [0]["license"]["id"]; // print ID
echo "&Order_ID=".$jsonArray [0]["license"]["order_id"]; // print Order ID
echo "&Product_ID=".$jsonArray [0]["license"]["product_id"]; // print Product ID
echo "&Key=".$jsonArray [0]["license"]["key"]; // print serial number associated with Order ID and Product ID
?>