PHP Classes

WAP Emulation

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  WAP Emulation  >  (Un) Subscribe thread alerts  
Subject:WAP Emulation
Summary:Some webs dont work in WAP version
Messages:2
Author:Jose
Date:2008-12-22 22:44:09
Update:2008-12-23 18:46:37
 

  1. WAP Emulation   Reply   Report abuse  
Picture of Jose Jose - 2008-12-22 22:44:09
Hi, I have a problem.

When I browse the page (http://portalecuador.ec/index.php?module=wap&func=chat&n=flor&c=2d8fe175f86&theme=wap) in desktop (Firefox o IE) "The Admob Test" Ad Show, but when I try emulate Wap browser with class the AdMob "Test Ad don't" Show, the follow is the class.

class
---------------------------
<?php

class HTTPBrowser
{
private $response_buffer_length;
private $user_agent;
private $referrer;
private $browse_url;
private $click_url;

private $http;

public function __construct()
{
$this->response_buffer_length=1000;
$this->user_agent="NokiaE50-1/3.0 (06.27.1.0) SymbianOS/9.1 Series60/3.0 Profile/MIDP-2.0";
$this->logged_user='';
}

private function SetupHTTP()
{
require_once("http.php");
if(!isset($this->http))
{
$this->http = new http_class;
$this->http->follow_redirect = 1;
$this->http->debug = 1;
$this->http->debug_response_body = 0;
$this->http->html_debug = 0;
$this->http->user_agent = $this->user_agent;
}
}

private function OpenRequest($arguments, &$headers)
{
if(strlen($this->Error=$this->http->Open($arguments)))
return(0);

if(strlen($this->Error=$this->http->SendRequest($arguments)) || strlen($this->Error=$this->http->ReadReplyHeaders($headers)))
{
$this->http->Close();
return(0);
}
if($this->http->response_status!=200)
{
$this->Error = 'the HTTP request returned the status '.$this->http->response_status;
$this->http->Close();
return(0);
}
return(1);
}

private function GetRequestResponse(&$response)
{
for($response = ''; ; )
{
if(strlen($this->Error=$this->http->ReadReplyBody($body, $this->response_buffer_length)))
{
$this->http->Close();
return(0);
}
if(strlen($body)==0)
break;
$response .= $body;
}
$this->http->Close();
return(1);
}

private function GetRequest($arguments, &$response)
{
if(!$this->OpenRequest($arguments, $headers))
return(0);
return($this->GetRequestResponse($response));
}

function browse()
{
$this->browse_url = '';
$this->click_url = '';
$this->SetupHTTP();
$this->browse_url = "http://portalecuador.ec/index.php?module=wap&func=chat&n=flor&c=2d8fe175f86&theme=wap";
$this->http->GetRequestArguments($this->browse_url, $arguments);
$arguments['RequestMethod']='GET';
$arguments['Headers']['Accept']= 'text/vnd.wap.wml;';
$arguments['Headers']['Referer']= 'http://www.google.com/';
$arguments['Headers']['Accept_Language'] = 'en-us,en;q=0.5';

if(!$this->GetRequest($arguments, $response))
return(0);

echo "URL: " . $this->browse_url;
echo $response;

return(1);

}
}

?>


-------------------------
file to load class
-------------------------
require_once("HTTPBrowser.class.php");

$brows = new HTTPBrowser();
$brows->browse();

---------------


Can you help me?

  2. Re: WAP Emulation   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-12-23 18:46:37 - In reply to message 1 from Jose
I am not sure what you mean by the "Test Ad" don't show. What happens? The WML page is not retrieved?