Error: detecting iPhone 3GS running iOS4

I have this HTTP request, I expected this, but WURFL is returning that. Please provide enough data to reproduce the problem.
Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Wed May 30, 2012 9:53 am

Hello,

Could you please assist me.

I have the latest version of WURFL set up on a test server. I can see test pages fine when I use a wireless laptop to access the pages, however, WURFL produces an error message when I try to access the test pages using an iPhone 3G. The error message is as follows:

Fatal error: Uncaughte exception 'Exception' with message: 'There is no device with ID [apple_iphone_ver4] in the loaded WURFL Data' in G:\Server\www\wurfl-php-1.4.1\WURFL\CustomDeviceRepository.php:105 Stack trace: #0 G:\Server\www.wurfl-php-1.4.1\WURFL\CustomDeviceRepository.php(208)

... etc (I have not reproduced the whole message).

Note: for my test server I use my Windows 7 workstation to which is attached a USB stick containing WAMP (specifically, MoWeS Portable II running Apache 2 and PHP5). I have altered the .htaccess file of Apache to allow for local access by the iPhone (the address of which is 10.0.0.4) and have also designated all files within my WURFL installation as having full access (read and write). I run MoWeS as administrator.

I would be grateful if someone could advise me how to resolve this error as I need to be able to detect popular devices such as the iPhone.

Many thanks and kind regards,

Grant Bailey
University of Western Sydney

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

Re: Error: detecting iPhone 3GS running iOS4

Postby kamermans » Wed May 30, 2012 1:25 pm

Hi Grant,

It sounds like the WURFL data is either not being loaded by the API, or is very old. Can you try downloading the latest WURFL data and giving it another try? You may need to delete your WURFL cache files to get the data to reload properly. Let me know if you need help with this.
Thanks,

Steve Kamerman
ScientiaMobile

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

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Wed May 30, 2012 9:21 pm

Steve,

Many thanks for your reply.

The WURFL XML file could not have been very old as I just installed it (and the API) two days ago. However, I took your advice and re-installed the XML file. I also deleted the files that were in resources/storage/cache and resources/storage/persistence. I double-checked the wurfl-config.xml file and it points to the correct file (in my case wurfl.xml). I also checked write access to the files and folders stored under resources and this is correct.

Unfortunately, I am getting the same error message when I try to open my test page using an iPhone. I can open the test page fine from the workstation and also, from a wireless laptop.

Would you please be able to suggest some alternative approach. Note that my iPhone shares the same wireless connection as the laptop and is connecting to the server using this connection and not a carrier service. Other than this I am not able to think of any other reason why an iPhone would not be able to access my test page. The iPhone can open non-WURFL pages fine.

I would be grateful for your further assistance.

Regards,

Grant Bailey

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

Re: Error: detecting iPhone 3GS running iOS4

Postby kamermans » Wed May 30, 2012 9:33 pm

Hi Grant,

Sorry about the trouble - this is very strange. Can you post your configuration and tell me which OS you are on so I can try to reproduce? If you are on linux, you can manually verify that this device exists in the WURFL with this command:

Code: Select all

$ grep apple_iphone_ver4 wurfl.xml
  <device id="apple_iphone_ver4" user_agent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/7D11" fall_back="apple_iphone_ver3_1_3" actual_device_root="true">
Thanks,

Steve Kamerman
ScientiaMobile

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

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Wed May 30, 2012 9:40 pm

Steve,

It's Windows 7 64-bit, I'm running WAMP under MoWeS (Apache 2 / PHP5).

Is there something I could print out to give you more information. Unfortunately I'm not running Linux on my workstation. I've been avoiding the real server (which is Linux) as I don't really want to use it for testing purposes.

Thank you,

Grant

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

Re: Error: detecting iPhone 3GS running iOS4

Postby kamermans » Wed May 30, 2012 10:02 pm

Ah yes, sorry about the duplicate info - I just realized that you already posted your setup in the initial post.

Can you please run this script and paste the output?:

Code: Select all

<?php
ini_set('display_errors', 'on');
error_reporting(E_ALL);

// Replace c:\\temp with the real path to the WURFL API
$wurflDir = 'C:\\temp\\WURFL-API-PHP\\WURFL';
$resourcesDir = 'C:\\temp\\WURFL-API-PHP\\examples\\resources';

require_once $wurflDir.'/Application.php';
$wurflConfig = new WURFL_Configuration_InMemoryConfig();
// You may need to edit this to use a different WURFL file
$wurflConfig->wurflFile($resourcesDir.'/wurfl.zip');
$wurflConfig->matchMode('performance');
$wurflConfig->persistence('memory');
$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
/* @var $wurflManager WURFL_WURFLManager */
$wurflManager = $wurflManagerFactory->create();
$wurflInfo = $wurflManager->getWURFLInfo();

echo "WURFL Info: \n";
var_export($wurflInfo);

echo "\nTesting iPhone UA\n";
$ua = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/7D11 TEST';
$device = $wurflManager->getDeviceForUserAgent($ua);
echo "Detected ID: $device->id\n";
You should see something like this:

Code: Select all

D:\temp>php php_api_test.php
WURFL Info:
WURFL_Xml_Info::__set_state(array(
   '_version' => 'For distribution with API 1.4, db.scientiamobile.com - 2012-03-26 09:10:51',
   '_lastUpdated' => 'Mon Mar 26 09:12:47 -0400 2012',
   '_officialURL' => 'http://wurfl.sourceforge.net/',
))
Testing iPhone UA
Detected ID: apple_iphone_ver4
Thanks,

Steve Kamerman
ScientiaMobile

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

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Wed May 30, 2012 11:42 pm

Steve,
Sorry but to run the script do I paste it into the top of my test file?
Grant

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Thu May 31, 2012 12:07 am

Steve,
Sorry for that last email, I worked out how to run the test script.

Here is the output:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Grant>G:\Server\php5\php.exe -f "G:\Server\www\wurfl-php-1.4.1\examples
\resources\php_api_test.php"
WURFL Info:
WURFL_Xml_Info::__set_state(array(
'_version' => '2.3.1, db.scientiamobile.com - 2012-03-10 17:06:57',
'_lastUpdated' => 'Sat Mar 10 17:08:56 -0500 2012',
'_officialURL' => 'http://wurfl.sourceforge.net/',
))
Testing iPhone UA
Detected ID: apple_iphone_ver4

C:\Users\Grant>

I hope this helps. Could you please advise me what to do next.

Many thanks,

Grant

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

Re: Error: detecting iPhone 3GS running iOS4

Postby kamermans » Thu May 31, 2012 8:58 am

Hi Grant, thanks for the test info. The test script shows that your system is working properly with a minimal configuration, so there is likely something wrong with your PHP API configuration. Can you post the API configuration that you're using? It probably looks similar to the test script I posted. Of particular interest are the $config->persistence() and $config->cache() settings.
Thanks,

Steve Kamerman
ScientiaMobile

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

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Thu May 31, 2012 5:32 pm

Steve,

Could you please describe how to do this.

Thank you,

Grant

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

Re: Error: detecting iPhone 3GS running iOS4

Postby kamermans » Thu May 31, 2012 8:12 pm

Sure, at some point you downloaded the PHP API and put it somewhere. Then you must have looked at our Getting Started guide, or at the example in the "examples\demo" folder that came with the API. You may still be using that example now, or you may have made your own file that references those files using "require_once" or "include" or something. Since you've said "I can see the test pages fine...", I'm assuming you've used the example files. Whatever the case, can you post the file that you're trying to visit from your browser, and, if that file is "examples/demo/index.php", can you also tell me if you've modified it, or the file that it includes called "examples/demo/inc/wurfl_config_standard.php"? In this example the "wurfl_config_standard.php" file contains the configuration for the API, and I'm assuming the problem is with that file. If this file is the problem, it's probably because of caching, so one place to start is to look for this code:

Code: Select all

// Setup Caching
$wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
... and remove it from the file, then try reloading the page to see if the error persists.
Thanks,

Steve Kamerman
ScientiaMobile

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

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Fri Jun 01, 2012 3:05 am

Steve,

I have attached the whole file to which my link relates, called chapter5. It consists of a folder called panic_button which itself consists of the files button.png, config.php, device.php, styles.css and index.php. The link that will not work in iPhone is the link to the file index.php. The chapter5 folder is located in G:\Server\www\_GMB_Web. I have a file in the folder G:\Server\www called index.html which is the localhost index page and contains the link to index.php.

The folder comes from the support site for the O'Reilly book 'Head First Mobile Web'. I have followed the examples in that book and have not made any alterations other than those required to locate the relevant folder (at the location given above). I have not tried the examples that came with the API.

As I said, the link works fine on the desktop and also when accessed using a laptop PC. Consequently I believe that the links are correct otherwise nothing would be displayed on any device.

Could you please have a look at the attached and advise me what to do.

Many thanks and regards,

Grant Bailey
(attachment)
Attachments
chapter5.zip
Zip of chapter5 folder (please advise if you cannot open it)
(44.76 KiB) Downloaded 635 times

Grant_Bailey
Posts: 8
Joined: Wed May 30, 2012 9:40 am

Re: Error: detecting iPhone 3GS running iOS4

Postby Grant_Bailey » Fri Jun 01, 2012 3:19 am

Steve,

Sorry I meant to add that I didn't amend the file called wurfl_config_standard.php which is located in G:\Server\www\wurfl-php-1.4.1\examples\demo\inc, would you still like me to do so.

Grant


Who is online

Users browsing this forum: No registered users and 15 guests