In this example, you will write a simple PHP script testing the originality of a digital image.
Step 1: Private and public key
Define your private and public key as variables. Private and public keys have been provided to you by Verifeyed.
$privatekey = "your_private_key_here"; $apikey = "your_public_api_key_here";
Step 2: The image or PDF file to test
Define the file you want to test.
$iurl = "http://verifeyed.com/wp-content/uploads/2013/05/insurance75.jpg"
Step 3: Signing the request
For security purposes you need to sign your request.
// generate a random nonce which should be unique per API call. $nonce = substr(sha1(rand(0,9000000).time()),0,30); //The current Unix time (i.e. the number of seconds since Jan. 1st 1970 GMT). //Requests that skew more than 15 mins from the server time will be rejected. $timestamp = time(); //signing the request $SIG = $privatekey.'get'.$timestamp.$nonce.'http://www.verifeyed.com/'."image_url=".strtolower($iurl); //encode sign using SHA1 $api_sig = sha1($SIG);
For compatibility reasons, every string passed to and from the Verifeyed API needs to be UTF-8 encoded.
Step 4: Making an API call
Now you can call Verifeyed API. The returned values are JSON encoded so we will use the built in decode function to get the values as array.
$APIAddress="http://www.verifeyed.com/api.php?image_url=$iurl&api_sig=$api_sig&api_key=$apikey&date=$date&nonce=$nonce"; $apidata = file_get_contents($APIAddress); $result = json_decode($apidata); print_r($result);
The result is stored as an array in the $result variable. The finished sample can be downloaded from our sample codes and used to test any image.