Page 1 of 1

Noob question about php and capabilities

Posted: Mon Aug 13, 2012 8:05 am
by centz
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";

?>

Re: Noob question about php and capabilities

Posted: Mon Aug 13, 2012 8:18 am
by kamermans
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.

Re: Noob question about php and capabilities

Posted: Mon Aug 13, 2012 8:56 am
by centz
Can you give me a sample code for show only Marketing Name or vendor+model?

Thank you.

Re: Noob question about php and capabilities

Posted: Wed Aug 15, 2012 8:35 am
by kamermans
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();
}

Re: Noob question about php and capabilities

Posted: Mon Aug 20, 2012 1:11 pm
by centz
Thank you.

;)