Setting up mysql and phpmyadmin on Mac OSX

well, I have been using MAMP for quite a long time. It’s a nice app. But then again, if I have native support on my own OS why use an third party app. Heh, actually I need this for some other reason.

Anyway, I am using Snow Leopard (little old though, don’t have money to buy the new one :P)

So, first download the latest version of .dmg from here.

Click mysql-5.5.19-osx10.6-x86_64.pkg (you may have different version) and install by following the screen.

Though this is optional, but I recommend to install MySQLStartupItem.pkg and run the MYSQL.prefPane as well. It will give you a MySQL panel on the System Preference. From here you can start/stop MySQL and also set for automated start upon server startup.

MySQL is accessible from /usr/local/mysql/bin/mysql

Set MySQL password for later use.

/usr/local/mysql/bin/mysqladmin -u root password SECRET

Installing phpmyadmin

Start Apache from System Preference (enable the web sharing). http://localhost should work now.

In Mac OSX PHP is not enabled by default. So enable PHP from /etc/apache2/httpd.conf by uncommenting the LoadModule php5_module        libexec/apache2/ line.

Download phpmyadmin from here.

Extract the files into /usr/local/ directory and rename it to phpmyadmin

Copy the and rename it to from the phpmyadmin directory.

Create a file into /etc/apache2/other/ and add the following lines

Alias /phpmyadmin /usr/local/phpmyadmin
<Directory /usr/local/phpmyadmin>
    Options Indexes
    Order allow,deny
    Allow from all

Restart Apache from terminal

apachectl restart

Open http://localhost/phpmyadmin/


Twitter bot in php with oAuth support

For last couple of days, I was looking into twitter API. One day I asked Lenin vai about a bot he made. He suggested me a Twitter bot. I was so excited at the very beginning. But when I had started I gone through some new features which I didn’t know and of course sometimes silly things give us so much pain 😛

About Tweet Bot:

The bot collects data from one or more locations and then tweets those one by one. Very simple php script. Usable with any website or blog and even any person at Twitter.

Tweet Bot Features:
  • oAuth supported
  • Parses feed with simple feed parser
  • Formatting links by shortening url
  • Format large title
Setting up Tweet Bot

Register application from here. For oAuth support I’ll be using Abraham William’s oAuth Library. Download the Twitter oAuth Library from github. The bot will be getting feeds from RSS. For that we need a parser. So, here we’ll be using Simplepie to parse RSS feed. Download the parser from here.

I always prefer to make a configuration file, just to keep the code clean and ready to use any time.



/* Change this url as needed */
define('FEED_URL', '');

Now let’s make our hand dirty with some coding 🙂


Connect to twitter via Abraham’s oAuth Library


Setup Simplepie to parse RSS feed.

$feed = new SimplePie();

We need to save the parsed link so that we can prevent the bot tweeting the same thing more than once. Twitter has word limitation of 140 words. So, the bot parses the title as well as the link. It always matches the latest link with the last tweeted one.

/* find the total number of available feed */
$max = $feed->get_item_quantity();

/* Get last tweeted data */
$last_saved_tweet = file_get_contents('last_tweet');

/* Get the first item on the feed */
$item = $feed->get_item(0);

/* permalink of the first item */
$itemlink = $item->get_permalink();

/* save the permalink into file */
file_put_contents('last_tweet', $itemlink);

/* title of the first item */
$itemtitle = $item->get_title();

/* length of the item title */
$titlelength = strlen($itemtitle);

if ($titlelength > 110) {
    $itemtitle = substr($itemtitle, 0, 107) . "...";

if ($itemlink != $last_saved_tweet) {

    /* shorten the url with tinyurl */
    $shortlink = file_get_contents("" . $itemlink);

    /* Update status with Abraham's oAuth Library */
    $connection->post('statuses/update', array ('status' => $itemtitle . " " . $shortlink));

So, now the Tweet Bot is ready to shoot! 🙂

Facebook Application Setup

Making web applications and desktop applications are something like cooking food. To cook a delicious food is not always necessary when we are learners. To cook foods the first thing we need is to know the fundamental tools we need. Then we might need a setup to make the food eatable. Then light up your burner and start cooking. The taste is yours!!!

Here I am going to discuss about basic facebook application setup on Facebook Platform.

Types of facebook application?

There are basically two types of applications on FB.
1. iFrame

How facebook application runs on facebook platform?


another form is,


Go to Account -> Application setting

I assume that you have a developer account. If not, follow the necessary steps to make one.

Then choose Developer from the menu and select  + Set Up New Application. Here you’ll be prompt to name your application. Give a name and choose Agree.

Now, you’ll see something like this. These are the basic information of your application.

Essential info
Essential info

Now select the canvas tab. Remember this is the crucial part of your application. Canvas page URL, is the address of your application on Facebook Platform. Canvas Callback URL, where application is hosted.

canvas url
canvas url

Canvas Setting, here we are to develop a iFrame application. So, choose iFrame from the option. Choose other options as you need.

Save settings and TADAAAA!!!!!!!!!!!! This is enough for a simple application to go on.

Location API on Aloashbei Platform

To work with Aloahbei platform, first configure the .wsdl file for LBS which is given on the Aloashbei site. Or you can download it from here.


class LBSRequest {
 public $msisdn;
 function  __construct($num) {
 $this->msisdn = $num;
 public $registrationID = "******";
 public $password= "******";

class GPInit {
 public $LBSRequest;

if(isset ($_POST['number'])) {
 $GPInit = new GPInit();
 $GPInit->LBSRequest = new LBSRequest("88".$_POST['number']);
 $result = $soap->requestLocation($GPInit);

Download full code

Send SMS with GrameenPhone API and PHP

To work with Aloahbei platform, first edit the .wsdl file for SMS which is given on the Aloashbei site. Or you can download it from here.

First, make a config.php file.

$soap = new SoapClient("");

$var['registrationID'] = "******";
$var['password'] = "****";
$var['sourceMsisdn'] = '88017********';
$var['smsPort'] = 7424;
$var['msgType'] = 4;
$var['charge'] = 0.00;
$var['chargedParty'] = '88017********';
$var['contentArea'] = 'gpgp_psms';

Now, make the main index.php file put the number and message into the $var array and call sendSMS api.

$var['destinationMsisdn'] = '88'.$_POST['number'];
$var['msgContent'] = $_POST['msg'];

$result = $soap->sendSMS( array ("SendSMSRequest" => $var) );

Download full code

Install phpmyadmin in ubuntu

In the previous article you’ve seen how to setup a LAMP server. Now if you want to install phpmyadmin open your terminal and type
sudo apt-get install phpmyadmin
follow the screen.

Now, open browser go to http://localhost/phpmyadmin/

you are done with your phpmyadmin installation. now, login with the password you provided earlier.

Install LAMP on ubuntu

Installing LAMP(Linux, Apache, MySQL, PHP) is not that tough now-a-days.

The easiest way
First open the synaptic manager with sudo synapti
then Edit ==> Mark Packages by Task
select LAMP server from the list and click OK.

Another easy way
go to terminal and type
sudo tasksel

press space bar to select and then tab to <ok>
Follow the screen.

One line command setup
go to terminal and type
sudo apt-get install lamp-server^
N. B the character ‘^’ is not a typo
Follow the screen, it’ll ask to change password for the root user of MySQL database.

Now. test Apache. Open a browser and type http://localhost/

if you see this, you are done with you apache installation.

test PHP installation. open terminal and type
sudo vim /var/www/test.php
save the file.
again, sudo /etc/init.d/apache2restart
now, open browser and try http://localhost/test.php

you see this, means your PHP installation is completed.

Test MySQL setup
go to terminal and type
mysql -u root -p

you see this, ahhhh….you are done with the famous LAMP installation 😀

For phpmyadmin setup try this