Skip to main content
Participant
August 3, 2024
Question

Connecting photoshop script to wordpress for Key activation

  • August 3, 2024
  • 1 reply
  • 432 views

Hello Guys,

 

I have created a photoshop script which is activated by connecting to my wordpress website to the license manager plugin and when the code is inserted into the script , it checks if the user license is active on the server to enable the script .
Is that possible to do ? 

i have tested this code :

The script code :

function verifyLicenseKey() {
var licenseKey = prompt("Enter your license key:", "");
var email = prompt("Enter your email:", "");

if (licenseKey && email) {
var url = "https://websitelinkdemo.com/api/proxy.php?license_key=" + encodeURIComponent(licenseKey) + "&email=" + encodeURIComponent(email);

try {
var result = httpRequest(url);
if (result && result.success) {
alert("License key is valid.");
main(); // If license is valid, run the main function
} else {
alert("Invalid or expired license key.");
}
} catch (e) {
alert("Failed to verify the license key. Error: " + e.message);
}
} else {
alert("You need to enter both a license key and an email to use this script.");
}
}

function httpRequest(url) {
var result = null;
var response = "";
try {
var socket = new Socket();
socket.timeout = 60;
if (socket.open(url, "GET")) {
while (!socket.eof) {
response += socket.read(1024);
}
socket.close();
response = response.substr(response.indexOf("\r\n\r\n") + 4);
result = JSON.parse(response);
} else {
throw new Error("Failed to open the socket.");
}
} catch (e) {
throw new Error("Error in HTTP request: " + e.message);
}
return result;
}

verifyLicenseKey();

function main() {
// Just a simple function for demo purposes
alert("Main function executed after license verification.");
}


the php file on the website:

<?php


$license_key = $_GET['license_key'];
$consumer_key = 'key';
$consumer_secret = 'secret';
$api_url = "https://websitelinkdemo.com/wp-json/lmfwc/v2/licenses/validate?key={$license_key}&consumer_key={$consumer_key}&consumer_secret={$consumer_secret}";

$response = file_get_contents($api_url);

file_put_contents('api_log.txt', "Request: $api_url\nResponse: $response\n\n", FILE_APPEND);

echo $response;
?>


Receiving this error in photoshop:

Failed to verify the license key. Error: error in HTTP request: Failed to open the socket.

thnx everyone in advance 

This topic has been closed for replies.

1 reply

Community Manager
August 5, 2024

Hi! I saw you tagge the post with Ps Automation API but it sounds like this is more of a scripting question. The Ps API is a headless version of Photoshop in the cloud that does not require the desktop to run tasks. I have moved your question over to the scripting community to see if anyone here might be able to help. 

Nads-24Author
Participant
August 11, 2024

Thnx Archy .