Tera Wurfl Device Image with Remote Web Service

Using Tera-WURFL's Remote Webservice Client. This includes the pre-packaged clients that come with Tera-WURFL and any other client you may have made to use the webservice.

Tera Wurfl Device Image with Remote Web Service

Postby bhupendra » Thu Jul 08, 2010 8:09 am

Today, I have modified the TeraWurflDeviceImage.php to make its use with Tera Wurfl Remote Web Service.
How i did this, is written below.
The defaullt code was
Code: Select all
public function __construct(TeraWurfl &$wurfl){
      $this->wurfl = $wurfl;
      $this->deviceID = ($this->wurfl->capabilities['tera_wurfl']['actual_root_device'])? $this->wurfl->capabilities['tera_wurfl']['actual_root_device']: false;
      $this->baseURL = '';
      $this->imagesDirectory = dirname(__FILE__) . '/device_pix/';
   }

And I modified it to
Code: Select all
public function __construct(TeraWurflRemoteClient &$wurfl){
      $this->wurfl = $wurfl;
      $this->deviceID = ($this->wurfl->capabilities['actual_root_device'])? $this->wurfl->capabilities['actual_root_device']: false;
      $this->baseURL = '';
      $this->imagesDirectory = dirname(__FILE__) . '/device_pix/';
   }

This how I utilized it using remote web service
Code: Select all
<?php
require_once 'TeraWurflRemoteClient.php';
require_once 'TeraWurflDeviceImage.php';
$wurflObj = new TeraWurflRemoteClient('http://localhost/Tera-WURFL/webservice.php');
$capabilities = array("product_info","tera_wurfl");
echo "<wall:br/>Designed for ";
$data_format = TeraWurflRemoteClient::$FORMAT_JSON;
$wurflObj->getCapabilitiesFromAgent(null,$capabilities,$data_format);
$image = new TeraWurflDeviceImage($wurflObj);
$image->setImagesDirectory('/device_pix/');
$image->setBaseURL('/device_pix/');
$image_src = $image->getImage();
if($image_src)
{
$image_html = sprintf('<wall:img src = "%s"/>',$image_src);
echo $image_html;
}
else
{
echo "No image available";
}
?>
bhupendra
 
Posts: 10
Joined: Wed Jun 23, 2010 1:01 pm

Re: Tera Wurfl Device Image with Remote Web Service

Postby kamermans » Thu Jul 08, 2010 12:03 pm

Thanks for the tip! I have added support for the TeraWurflRemoteClient in the Tera-WURFL source. It is available from Github: http://github.com/kamermans/Tera-WURFL/ ... 81d#diff-0 and will be included in the 2.1.3 release (release date not set yet).
Thanks,

Steve Kamerman
Tera-WURFL Author
COO of ScientiaMobile

IMPORTANT ANNOUNCEMENT! Tera-WURFL and WURFL have joined forces! We have launched ScientiaMobile to provide commercial support for our device detection solutions.

Tera-WURFL.com | Device Explorer
kamermans
Site Admin
 
Posts: 323
Joined: Wed Mar 10, 2010 12:06 pm
Location: Fort Worth, TX


Return to Using the Remote Webservice

Who is online

Users browsing this forum: No registered users and 2 guests

cron