Php api exampleFrom Skoffer One Click ScreencastingThe idea of the code example below is this:
please keep in mind: via javascript it is only possible to insert text into forms from popups on the same domain. www.yourdomain.tld and yourdomain.tld are two differnt domains for javascript, too.
The below example is for the website-software MediaWiki (MediaWiki´s textfield has the Element-ID "wpTextbox1"), but can be used for most software when the Element ID in Javascript code that inserts the text opener.document.getElementById('wpTextbox1').value=opener.document.getElementById('wpTextbox1').value+\"<TEXT TO INSERT>\";
is adapted to the Element-ID of the desired software.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
background-color: #000000;
color: #e8f4f8;
font-size:14px
}
:link {
color: #FFFFFF;
}
-->
</style>
<title>screen-recorder initiator</title></head>
<body>
<?php
$skofferid = $_GET['skofferid'];
// removing possible wrong chars from the id
$skofferid= preg_replace ("/[^A-Za-z0-9.-]/","",$skofferid);
// if there is a GET variable "skofferid" this PHP file should generate HTML code with a Javascript to insert the ID into the Mediawiki text-field
if (isset($_GET["skofferid"]))
if($skofferid == "")
{
// if $skofferid is empty: insert nothing (happens when the user clicks the screen-recorder´s close button.
echo "<script language=\"javascript\" type=\"text/javascript\">
opener.document.getElementById('wpTextbox1').value=opener.document.getElementById('wpTextbox1').value+\"\";
parent.close();
</script>";
}
else
// if $skofferid is not empty: insert the ID
{
echo "<script language=\"javascript\" type=\"text/javascript\">
opener.document.getElementById('wpTextbox1').value=opener.document.getElementById('wpTextbox1').value+\"[skoffer $skofferid]\";
parent.close();
</script>";
}
// if there is no GET variable "id", the JAVA applet should be started. When the user finished a new recording, the applet saves the new recording and this PHP file is called again with the ID of the new recording as GET var "skofferid" (so this PHP file inserts the ID into the text-input field of the website-software)
else
echo "<script type=\"text/javascript\">
if (navigator.javaEnabled() != true) {
alert(\"Sorry, the screen-recorder can´t start. Java has to be enabled in your browser. Please go to www.java.com to download the latest version.\");
document.write(\"Sorry, Java is not enabled in your browser.<br />Java is available from <a href='http://www.java.com' target='_blank'>http://www.java.com</a>\");
}
</script>
<center><applet code=\"com.skoffer.SkofferApplet\" archive=\"http://api.skoffer.com/v1/skoffer.jar\" name=\"Skoffer.com Screencast Recorder\" width=\"200\" height=\"180\" MAYSCRIPT></center>";
?>
</body>
</html>
[skoffer $skofferid]
[skoffer 123456789]
|