Lightshot API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function addLog($text, $debug = false) { | |
if ($debug) { | |
file_put_contents("debug_log.txt", $text . PHP_EOL, FILE_APPEND); | |
} | |
} | |
function makeResponse($request) { | |
return array( | |
"jsonrpc" => "2.0", | |
"id" => $request["id"], | |
"result" => array( | |
"url" => $request["params"]["img_url"], | |
"info" => "The image saved to user gallery (short url)", | |
"success" => true | |
) , | |
); | |
} | |
//Get the raw POST data. | |
$raw_json = file_get_contents("php://input"); | |
addLog("Request: " . $raw_json); | |
//Decode the JSON request. | |
$request = json_decode($raw_json, true); | |
addLog("img_url: " . $request["params"]["img_url"]); | |
//Construct the response. | |
$response = makeResponse($request); | |
$response_json = json_encode($response); | |
addLog("Response: " . $response_json); | |
//Set the response header and echo the response. | |
header('Content-type: application/json'); | |
echo $response_json; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment