Sadiqur Rahman

Posts Tagged ‘php5

Recently I have sate for the ZCE (Zend Certified Engineer) exam on 28 January 2009, And I like to share my experience to all so that everyone can get prepared for ZCE Exam. However, Let me go to the topics.

The PHP 5 Certification exam covers the following topics:
PHP Basics
XML and Web Services
Object Oriented Programming
Streams/Network Programming
Design Pattern
PHP 4/5 Differences
Strings and Regular Expression
Databases Access
Web Features

Now let me say where you should study…

1) PHP Manual is the best reference to get prepared. This is not only the main reference but you must have deep eye on this tutorial if you are serious to be success. without following PHP Manual it is quite impossible to pass.
I suggest everyone to keep eyes on every functions mentioned into PHP Manual. Array Functions, String Functions and Database (MySQLi, PDO) and Exception handling are notable topics.

2) ZCE Study Guide You can get from but remember its not FREE.. you have spend a little money for this guide. You will learn from this guide Basic Language and basic of every topic. specially you will get knowledge from this guide on Security and Design Pattern etc…

3) Many PHP Forums You will learn manything from Forums and Newsgroup.

4) Mock Test Remember there is no similarity between mock and real exam but you will get some idea about your real exam.

5) Confidence if you do not have enough confidence you do not need to loss your valuable money 🙂


You already might know that the giant company YAHOO provides some API to facilitate the application development process. One of them is Yahoo BBAuth API. I am glad to inform you that I wrote a wrapper class on Yahoo Browser Based Authentication (BBAuth) to make it easy and convenient.

So…, what’s BBAuth? What’s the point for using this class?

Well, a BBAuth API will provide you a WSSID and a cookie which will be destroyed after one hour (idle time) automatically (no way L ). After a successful login you will be able to access the users:

  • read and write to your data in Yahoo! Mail
  • read and write to your data in twlife
  • read your data in Yahoo! Address Book
  • read and write to your data in boss
  • read and write to your data in music
  • read and write to your data in twk

How it works:

The image below will illustrate the life cycle.

Yahoo BBauth

Yahoo BBauth

Now lemme tell you the entire process:

  1. Register your application
  2. Log in your users
  3. Use the user’s credentials to make web service calls

Wrapper Class  class.YahooAuth.php

Download from

/* Description: Class for Yahoo BBAuth API
 * @author: Sadiqur Rahman
 * @param: $AppID=Yahoo BB Authentication Application ID
 * @param: $secret=Yahoo BB Authentication Secret key
 * @param: $AppData=Your application data which is an optional parameter
 * @Links:
 * @Author-URI:
 * @Author-EMail:
 * License: GPL
 * Version: 1.0.0
//declaring the class
class YahooAuth {

    protected $AppID;
    protected $secret;
    public $AppData;

    function __construct($AppID=NULL,$secret=NULL,$AppData=NULL){

        if (isset($AppID) && (!empty($AppID))){
            $this->AppID = $AppID;
            global $YahooAppID;
            $this->AppID = $YahooAppID;

        if (isset($secret) && (!empty($secret))){
            $this->AppID = $secret;
            global $YahooSecret;
            $this->secret = $YahooSecret;

        if (isset($AppData) && (!empty($AppData))){
            $this->AppData = $AppData;

        if (!headers_sent()) {


    //Signature generation for Yahoo BBAuth
    protected function signature($path,$data,$ts){
        return md5($path.$data."&ts=".$ts.$this->secret);

    //Generating login URL
    function generate_url(){

        $url = ""
        return $url;

    //Automatically redirecting Yahoo login page
    function login(){

        if (!headers_sent()) {
            header('Location: '.$this->generate_url());
            // If Header already sent, redirect to Yahoo using Javascript.
        } else {
            echo "<script type=\"text/javascript\">
                  window.location = \"".$this->generate_url()."\"
<div align='center'>If you are not redirected within 5 Seconds <a " .
                  "href=\"".$this->generate_url()."\">Click Here</a>";

    //Getting and verifying data from cookie and WSSID given by yahoo
    //and storing data into session for future use
    function get_credentials($token) {

        $url = ""

        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_URL, $url );
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
        $store = curl_exec( $ch );
        $xml = curl_exec( $ch );

        if (  preg_match( "/(Y=.*)/", $xml, $match_array ) == 1 ) {
            $COOKIE = $match_array[1];
        if (  preg_match( "/<WSSID>(.+)<\/WSSID>/", $xml, $match_array ) == 1 ) {
            $WSSID = $match_array[1];
        if (  preg_match( "/<Timeout>(.+)<\/Timeout>/", $xml, $match_array ) == 1 ) {
            $timeout = $match_array[1];

        $_SESSION['COOKIE'] = $COOKIE;
        $_SESSION['WSSID'] = $WSSID;
        $rv = array();
        $rv["COOKIE"] = $COOKIE;
        $rv["WSSID"] = $WSSID;
        $rv["timeout"]   = $timeout;
        return $rv;

    //some magic methods for your convenience
    function __get($name){
        return $this->$name;

    function __set($name,$value){

    function __toString(){

    function __destruct(){

Example Usage  index.php


//implementing lazy loading
function __autoload($class){

$YahooAppID=".lND7LnIkY5jBHPMGmMhBBkWWpbJ6_gew9XLo.B5.d8-"; //your AppID will be here
$YahooSecret="555060ec4069cf7f67ddb84339f8701c"; //your Secret key goes here

$obj= new YahooAuth(); //Instantiating the class

if (isset($_GET&#91;'token'&#93;) && isset($_GET&#91;'appid'&#93;)){

if ($_SESSION['valid_user']){
    echo "Congratulation! You are logged in.<br \>";
    echo "<a href='".$_SERVER&#91;'PHP_SELF'&#93;."?logout'>LogOut</a><br \>";
    echo "
    echo "</pre>
    echo "You are not logged in.<br \>";
    echo "<a href='".$obj->generate_url()."'>Click Here to logIn</a>";

Download from

My Qualification

My Classes on


July 2018
« Jan    

Flickr Photos

Blog - Sadiqur Rahman