how to get report data from basic report services like keywordsummarybyday using the yahoo search marketing ysm api in php

Here I present a step by step way to get report data ( from the Yahoo Search Marketing API (YSM). I Give the example to get the report data from the KeywordSummaryByDay.

The yahoo search marketing api based on the SOAP web services. I assume that you have the official client YahooEWSClient.Php. Also you have Production key or Test key information (SandBox account). All of the codes are based on YahooEWSClient.Php.

The steps to get report data are followings :

Details description found (


_STEP 1 : Initialize SOAP clients for a Basic Report Services.

_STEP 2 : Report Request for particular Account Id .

_STEP 3 : Get Report List

_STEP 4 : Get Output Report Url

_STEP 5 : Call the url through http get method

_STEP 1 : Create a Basic Report Service

YSM has many Services. To get report data they provide the BasicReport services.

_STEP 2 : Request a report that aggregates metrics for a specific account. It has 2 parameters .It return a report id.

1. accountID which is a string .

it has 4 elements

· dateRange

· endDate

· reportName

· reportType

· startDate

_STEP3 : Get report list

This step may be you omit. Actually this return the report id which are Complited. It takes a parameter of true/false. If true then return only the completed report id.

_STEP4 : Get Output Report Url

Return a URL that you can use to retrieve the report (specified by reportID) using the HTTP GET method. For security reasons, the URL is available for 5 minutes only.

If the report is not ready, the return string will contain the status of the report rather than the URL.

It takes parameter for 2 .

· Report id

· File format . (FileOutputFormat here you can specify whether you get the data in xml,csv etc format.)

_STEP 5: Call the url through http get method

You can use curl to get the data from url.

Here is a sample code :

$basicReportService =
createClient( EWS_VERSION. “/BasicReportSer vice”, $accountID);

createReport( $basicReportServ ice, $accountID);

//createReport method defined
function createReport( $basicReportServ ice, $accountID)
debug(‘Calling CreateReport’ );
$retObj = execute($basicRepor tService,
‘addReportRequestFo rAccountID’ ,
array(‘accountID’ => $accountID,
‘reportRequest’ => array(‘reportName’ => ‘keyword_summary_ report’,
‘reportType’ => ‘KeywordSummaryByDa y’,
‘dateRange’ => ‘Last7Days’

$reportID = $retObj->out;
debug(“ReportID obtained:”+$ reportID) ;

$reportURL = “”;
$counter = 0;

while ($counter++ < 5) {
$retObj = execute($basicRepor tService,
‘getReportOutputUrl ‘,
array(‘reportID’ => $reportID,
‘fileFormat’ => array(‘fileOutputTy pe’ => ‘CSV’,
‘zipped’ => false
debug(‘reportURL- —‘.$retObj- >out);
if ($retObj->out == ‘PENDING’) {
else {
$reportURL = $retObj->out;
debug(“Waiting for Report URL …”);
sleep(60);// poll interval 60 secs

if($reportURL != ‘PENDING’){

debug(“REPORT URL->”.$reportURL) ;
$downloadLocation = downloadURL
($reportURL, ‘keywordsummaryb yday’,’CSV’ );

For further details you can contact with me.



Virtual Bangla keyboard for facebook Application

So now we can write bnagla in Facebook by Virtual keyboard. Here is the demo application of virtual keyboard

After seeing the virtual keyboard(vc) from the hasin bhai blog, I have planned to do that in facebook application. But I hear that it can be used by iframe. So I think to do that in FBJS as a result it will be easily integrated in any facebook application. So work on the I have done the Virtual application by FBJS. Thanks Allah to do that very exciting work.

Also thanks hasin bhai to encourage me and Anis bhai, Emran Hasan who helped me lot to complete that.

You can see the demo here :

After doing that I learn some beauty of FBJS .The next I will share the challenges I have faced to do that in fbjs .

Note : If you do not see the bangla  font  then you have to install the unicode, you can follow the instruction from there :

Speed Up your Web Application by CodeIgniter

Now a days one of the big issue you have to focus that to High speed your web site performance. I have read a nice article” Performance tips for web applications” where focus the performance tips of web application. These tips can easily apply by codegIniter . Let see some of the tips below.

Some of the techniques are :

  • Enable GZIP Components.
  • Make Fewer Http Request .
  • Adds an Expires Header.
  • Minify JavaScript.

Enable GZIP Component :

In the system/application/

change the config variable true

   1: $config['compress_output'] = TRUE;

Make Fewer HTTP Request :

1. Caching the site.

Each time file loads from your web server, it generates an http request. So you can reduce number of http requests by caching some contents which are almost static or changes very rarely. if these contents are loaded from browser cache, there will be no request for them over HTTP.

So you can easily caching your web Pages in the CodeIgniter :

Enabling Caching

To enable caching, put the following tag in any of your controller functions:

   1: $this->output->cache(n);

Where n is the number of minutes you wish the page to remain cached between refreshes.

The above tag can go anywhere within a function. It is not affected by the order that it appears, so place it wherever it seems most logical to you. Once the tag is in place, your pages will begin being cached.

To set data you can do it by the

   1: $this->output->set_output($data);

Also you can manually set header :


Permits you to manually set server headers, which the output class will send for you when outputting the final rendered display. Example:

   1: $this->output->set_header("HTTP/1.0 200 OK");
   2: $this->output->set_header("HTTP/1.1 200 OK");
   3: $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
   4: $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
   5: $this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
   6: $this->output->set_header("Pragma: no-cache");

2. join multiple css or js file into single css or js file .

It can be done in many ways . But in the CodeIgniter forum i find some ways to do that . You can check out here. The below code is the forum message :

Following is the controller to join multiple cs or jss
file in to one, and hence making fewer server request to speed up the things little bit.

Just add following in to your controllers. save as file.php Set the path of your
js and css files accordingly.

   1: <?php
   2: class File extends Controller
   3: {
   4: function File()
   5:     {
   6:         parent::Controller();
   7: /*Set your own path here*/
   8: $this->_path = "./public/";
   9: }
  10: function index()
  11: {
  12: echo "";
  13: }
  14: function js()
  15: {
  16:         $segs = $this->uri->segment_array();
  17:         foreach ($segs as $segment)
  18: {
  19:             $filepath = $this->_path.$segment.'.js';
  20:             if(file_exists($filepath))
  21: {
  22:                 readfile($filepath);
  23: }
  24:         }
  25:     }
  26: function css()
  27: {
  28:         $segs = $this->uri->segment_array();
  29:         foreach ($segs as $segment)
  30: {
  31:             $filepath = $this->_path.$segment.'.css';
  32:             if(file_exists($filepath))
  33: {
  34:                 readfile($filepath);
  35: }
  36:         }
  37:     }
  38: }
  39: ?>

Now you can add any number of files with just single line of code,and with single
For e.g. If you want to include two css file , foo.css and bar.css , the code is ,

   1: <link rel='stylesheet' type='text/css' media='all' href='<?php echo site_url("file/css/foo/bar");?>' />

The alternative of that one is :

got a script from somewhere that gzips the css/js, caches the compilation of the files etc. Since I generally use jQuery I my controller also has the function jQuery. I can now do

<?PHP echo site_url(asset/jquery); ?>

This redirects to a similar function as you have but a bit shorter.

Adds an Expires Header:

you can add expire header by the Ci library output class.

Minify JavaScript:

You can minify javascript by packed, Minify.

AJAX In Facebook

Now days Ajax is doing a very important rule .That’s in the face book application , it also very necessary .

In this section I will describe the ajax method for facebook application.

I assume that the rader will have an idea about the ajax and some idea of FBJS.

First I focus the categories of ajax method in facebook.

There are different ways you can perform ajax in facebook.

1. MOCK Ajax .(

2. TypeHead Ajax. ( )

3. Using FBJS/ AJAX ( )

I feel comfort for the last one, because it quite similar with jquery. ( ).

Also “FBJS is Face book’s solution for developers who want to use JavaScript in their Facebook applications. We built FBJS to empower developers with all the functionality they need, and to protect our user’s privacy at the same”

So let’s start with the FBJS/ AJAX

At first see the features of AJAX.

1. FBJS supplies a very powerful AJAX object

2. It supports retrieving JSON, FBML, or raw text from remote servers.

3. To use it, just instantiate a new Ajax class.

4. It has an event handler which fires when an AJAX call returns

5. It has an event handler which fires when an error occurs during an AJAX call

6. It can check whether user login.

7. Data send through post.

Now we look at the AJAX Method:


This can be Ajax.RAW, Ajax.JSON, or Ajax.FBML.


The response from your server will be returned to your callback in its original form.


The response from your server will be parsed as a JSON object and returned to your callback in the form of an object. Properties of your JSON object which are prefixed with “fbml_” will be parsed as individual FBML strings and returned as FBML blocks. These blocks can used on a DOM object with the setInnerFBML method.


The response from your server will be parsed as FBML and returned as an FBML block. This block can used on a DOM object with the setInnerFBML method.


An event handler which fires when an AJAX call returns.


An event handler which fires when an error occurs during an AJAX call


If you set this to true the AJAX call will require the user to be logged into your application before the AJAX call will go through. The AJAX call will then be made with the regular fb_sig parameters containing the user’s identity. If they refuse to login, the AJAX call will fail.

post ( url, query)

Start an AJAX post. url must be a remote address, and query can be either a string or an object which will be automatically converted to a string.

Note: be careful about the url. Use the callback url . Do not write facebook url. Like ()

Like use this :

not to use :

Now we start through step by step :

1. Create an instance of AJAX class. Like : var ajax = new Ajax();

2. Set the response type of ajax.

Like: if you use FBML then use

ajax.responseType = Ajax.FBML;

3. Set the require login. like : ajax.requireLogin = true;

4. Now you write the function that will handle the event after success of ajax call.

Like :

ajax.ondone = function (data) {

document.getElementById (‘message’).setInnerFBML(data);


Note: here data is the result of Ajax.

5. You can also set onerror for handling the error.

6. Call the url through post method .Like

var params={“user”:user_id,”video_id”:video_id}; //add parameters as comma separated “param”:value‘callbackurl not facebook url l,params);

Well you see here you can see that post method has two parameter. post callbackurl,parameter);

There is useful links from where you can get the full example of ajax .

Jquery youtube Plugin

Recently i have been working on a project where to get youtube videos. I have to make ajax way .I make a jquery plugin to get the videos. here is the demo example of jquery youtube plugin example demo.

You will get the full description here .
Here i give you brief description about the plugin and must be know that it will be change after getting your comments, suggestions.

About jquery youtube Plugin


jquery youtbe plugin is a javascript interface for Google YOUTUBE API written by jquery. Now it is alpha version .

 Watch Demo Example 


Features (sample)

  • no server-side script required..
  • easy to implement:
  • support customs configaration :

    { type :'search',
    keyword :'searchWord
    ' } );
  • support custom callback function youtube(
    type :'users',
    keyword : 'searchWord'
    , callback : 'myFunction' } );
  • supports paging result, most viewd youtube and many more.
  • Builtin BlockUI plugin
  • Run video inline or link to the youtbue.
  • If you have question or comments, please use the commetns here jquery plugin comments to the jQuery mailing list, or send me an (


jQuery youtube, Alpha 1 Uncompressed

Configaration Settings

Settings Default Type Options Explanation
type null string search,usres,playlist,category allowed what type of video you want
keyword null string optional search keyword
playlist_id null string    
url null string   specific url of vidoes
start_index null int   This is used for paging . From which you want start
max_results null int   return maximum videios
format null string    
inlineVideo true boolean   do you want to redirect to youtube, or play inlinevideo
blockUI true boolean   do you want to playVideo in block UI

Bangla insert and retrive using php & mysql

Lets see how to insert and retrive banlga font into the Mysql Database using PHP. We see the step for that.

  • First we Create a MySql database and tables which supports Bangla.
  • Insert Bangla value in the database .
  • Retrieve Bangla from the database.
    • Create Database to support Bangla :
      We give the database name bangla and it has 1 table which name is profile .We do that by phpMyadmin :

    • To create the database set character utf8_general_ci.
    • database_create.jpg

    • db_table1.jpg
    • db_field-1.jpg
      To keep things simple and easy to understand open the mysql command

    • mysql> set names ‘utf8′;
    • mysql> create database bangla character set utf8 collate utf8_general_ci;
    • mysql> use bangla;
    • mysql> create table profile (profile_name varchar(100) character set utf8 collate utf8_general_ci);

    Insert Bangla :
    So we create a database. Now we insert the value into the database. Insert Bangla Value in the database :
    We create a simple form :

    Input Form


    Then we will insert into the database :

    We create a coonection .

    1. $c = mysql_connect(“localhost”,”root”,””);
    2. mysql_select_db(‘bangla’) or die (mysql_error());
    //******These two line are used for Bangla Character *********/
    3. mysql_query(‘SET CHARACTER SET utf8’);
    4. mysql_query(“SET SESSION collation_connection =’utf8_general_ci'”) or die (mysql_error());

    You must add these two lines just after selecting the database, i.e mysql_select_db() function.
    mysql_query(’SET CHARACTER SET utf8′);
    mysql_query(”SET SESSION collation_connection =’utf8_general_ci’”);

    If you want to see more details then look at here (

    Now we will insert :
    mysql_query(“insert into profile values($_POST[“username])) or die (mysql_error());
    echo ‘saved into database’;
    echo ‘Not posted’;

    Now we check how the font stores into the database .
    Retrieve Bangla from the database:
    The display is as simple as retrieve other database.

    $res = mysql_query(“select * from profile”,$c);
    echo “
    Display resrult from database
    echo “————————“;
    while($row = mysql_fetch_array($res))
    echo $row[‘profile_name’] .’
    echo “————————“;

    Now one of the thing is how you write bangla in the webpage
    I fyou have no font please download the free software

    Avro software

    Joining Right Brain Solution

    rbs.pngRight Brain Solution

    I have joined the Right Brain Solution . After 7 months at ECBB , I make up my mind to switch my job to take new challenges and working with talented team members.

    After met with the Md. Emran Hasan, who is a CTO and Co-founder , I realize that he is not only technically great, but also has a very high goal set up in his mind and good managerial skill. I also found in the team the very hard worker, great learner and obviously the creative minded which reflects the company name Right Brain Solution.

    I hope so i will pass a great time with the Md. Emran Hasan and obviously with talented team members.

    Saidur Rahman,
    Software Engineer,
    Right Brain Solution Ltd