Copy link to clipboard
Copied
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={$con...}";
$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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thnx Archy .
Find more inspiration, events, and resources on the new Adobe Community
Explore Now