Noob question about php and capabilities

Questions about the WURFL Cloud service.
centz
Posts: 3
Joined: Mon Aug 13, 2012 7:58 am

Noob question about php and capabilities

Postby centz » Mon Aug 13, 2012 8:05 am

I want my website show marketing name(marketing_name) look like this BlackBerry 8100 Pearl, Nokia 8800 Scirocco, Samsung M800.

But my code does't work. Please help me .

Code: Select all

<?php
require_once dirname(__FILE__).'/../Client/Client.php';

try {
	// Create a WURFL Cloud Config
	$config = new WurflCloud_Client_Config();
	
	// Set your API Key here
	$config->api_key = '301618:I10TsGtO2Ejy9ZYlFQzw7mki4rapCKBR';
	
	// Create a WURFL Cloud Client
	$client = new WurflCloud_Client_Client($config, new WurflCloud_Cache_Null());
	
	// Detect the visitor's device
	$client->detectDevice();



$phone = $client->getDeviceCapability('marketing_name');

echo "$phone";

?>

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: Noob question about php and capabilities

Postby kamermans » Mon Aug 13, 2012 8:18 am

It looks like you've missed some of the code in your post, as there is no catch(){} block, but assuming the code did run, it still might not display anything, since the marketing_name property is not always used. You are probably more interested in the brand_name/model_name.
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

centz
Posts: 3
Joined: Mon Aug 13, 2012 7:58 am

Re: Noob question about php and capabilities

Postby centz » Mon Aug 13, 2012 8:56 am

Can you give me a sample code for show only Marketing Name or vendor+model?

Thank you.

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: Noob question about php and capabilities

Postby kamermans » Wed Aug 15, 2012 8:35 am

You would need three capabilities for this example, but it would show the make/model and optional marketing name:

Code: Select all

<?php
require_once dirname(__FILE__).'/../Client/Client.php';

try {
   // Create a WURFL Cloud Config
   $config = new WurflCloud_Client_Config();
   
   // Set your API Key here
   $config->api_key = '123456:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
   
   // Create a WURFL Cloud Client
   $client = new WurflCloud_Client_Client($config, new WurflCloud_Cache_Null());
   
   // Detect the visitor's device
   $client->detectDevice();

   $phone = $client->getDeviceCapability('brand_name').' '.$client->getDeviceCapability('model_name');
   if ($client->getDeviceCapability('marketing_name')) {
   		$phone .= ' ('.$client->getDeviceCapability('marketing_name').')';
   }
   echo $phone;

} catch (Exception $e) {
	echo "Error: ".$e->getMessage();
}
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

centz
Posts: 3
Joined: Mon Aug 13, 2012 7:58 am

Re: Noob question about php and capabilities

Postby centz » Mon Aug 20, 2012 1:11 pm

Thank you.

;)


Who is online

Users browsing this forum: No registered users and 22 guests