Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 18th, 2024, 12:25 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Windows Publication - JSON via PHP
PostPosted: July 8th, 2016, 10:33 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
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-code

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

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Last edited by lmc on July 8th, 2016, 10:54 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Windows Publication - JSON via PHP
PostPosted: July 8th, 2016, 10:49 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
A useful PHP page for JSON and PHP, etc: https://jonsuh.com/blog/convert-loop-th ... s-objects/

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Windows Publication - JSON via PHP
PostPosted: July 9th, 2016, 11:18 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Thanks guys,

Never heard of OWL, but will take a look.

I'll tweet that JSON link as it contains a useful summary.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group