Shop OBEX P1 Docs P2 Docs Learn Events
Webbased API — Parallax Forums

Webbased API

TumblerTumbler Posts: 323
edited 2012-08-09 08:37 in General Discussion
Hi,

I'm working on a webbased API to generate images and searchin for some perl scripters (or other languages) for testing.

I can't test other scripts, only PHP. So it would be awesome if somebody can take a look at it and test it.

PS: there is no error handling used here (only testing for valid parameters)

To generate an image in php:
<?php
// make a stdclass
    $test = new stdclass;
    $test->Vkey="dHVtYmxlcg==aWxzZTRtZQ==";
    $test->width = 480;
    $test->height = 272;
    $test->title = 'This is the title of the image';  


// encoded it with json
    $encoded = json_encode($test);


//retrieve XML with simpleXML
    $target = 'http://www.tumbler.be/api/?g=' . $encoded;
    $xml_object =  new SimpleXMLElement($target, NULL,true);


//test if we have an error
    if (!empty($xml_object->error)) {
      echo  $xml_object->error;
    }
    else {
    //show result
      echo '<img src="'.$xml_object->image.'" />';
    }




?>

this will produce an image like this:
This is the title of the image.png

Thx in advance

Comments

Sign In or Register to comment.