Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Connecting photoshop script to wordpress for Key activation

New Here ,
Aug 03, 2024 Aug 03, 2024

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 

TOPICS
Scripting
359
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 05, 2024 Aug 05, 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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2024 Aug 11, 2024
LATEST

Thnx Archy .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines