Working with IDE One API

I am very lazy to write any post. To be frank, I don’t find anything to write :roll:

Today I found something to write about. It’s nothing, but some bunch of codes. I’ll describe them, they are self explanatory. The idea is to write code and compile them On-The-Cloud. It’s actually using “IDE One” api to compile any programming source code, and give the result back. It’s useful in the devices where you can’t use any compiler, like mobile phones. There are already many applications for mobile that works the same way. Today I just wrote it in PHP. It uses SOAP protocol to communicate to the server. Enough talks :P

<?php

$user = 'tareq'; //--> API username
$pass = '********'; //--> API password

$lang = 1; //--> Source Language Code; Here is 1 => C++

$code = '#include<stdio.h>
int main() {
	printf("hello");
	return 0;
}
'; //--> Source Code

$input = '';
$run = true;
$private = false;

//create new SoapClient
$client = new SoapClient( "http://ideone.com/api/1/service.wsdl" );

//create new submission
$result = $client->createSubmission( $user, $pass, $code, $lang, $input, $run, $private );

//if submission is OK, get the status
if ( $result['error'] == 'OK' ) {

    $status = $client->getSubmissionStatus( $user, $pass, $result['link'] );

    if ( $status['error'] == 'OK' ) {

        //check if the status is 0, otherwise getSubmissionStatus again
        while ( $status['status'] != 0 ) {
            sleep( 3 ); //sleep 3 seconds
            $status = $client->getSubmissionStatus( $user, $pass, $result['link'] );
        }

        //finally get the submission results
        $details = $client->getSubmissionDetails( $user, $pass, $result['link'], true, true, true, true, true );
        if ( $details['error'] == 'OK' ) {
            var_dump( $details );
        } else {
            //we got some error
            var_dump( $details );
        }
    } else {
        //we got some error
        var_dump( $status );
    }
} else {
    //we got some error
    var_dump( $result );
}

Here is a working demo. It might be buggy, may be you could help me to find those bugs :)

Locate phone location with GP Aloshbei location API and visualize with google maps API

We have built our main Aloashbei class in the previous post. Now we will extend it to locate any GrameenPhone number. But currently, as a developer you can only track your number for testing purpose.

File Structure:

  • class.Aloashbei.php
  • class.AloashbeiLBS.php
  • location.php
  • includes/WebService_Aloashbei_LBS_WS.wsdl

Read the rest of this entry »

PHP class for sending, receiving and checking SMS status with GrameenPhone’s Aloashbei API

I saw everyone is participating in the GrameenPhone Aloashbei API contest and it’s began and I am late :P . So why not doing something that makes other’s life easy? So I decided to make a PHP class to do that job for you. You don’t need to know how to work with SOAP. Just instantiate a class, set the parameter and send, VOILA!!!

With the Aloashbei SMS API, you can send SMS, Check the SMS status and receive SMS. You can track location of any GP mobile number with the Location Locator API. It will provide you the longitude and latitude of the phone numbers current position. You can send MMS with the MMS API. You can charge any user who buys any content through the Charging API.

So we are going to build php class that will do these thing easily. Here I will built the SMS class. We can send SMS to any number and if it’s successful, it will return us a message ID. With this message ID, we can check the status of that sent message. To make a complete Aloashbei API class, we’ll first make a basic class and will extend it for other purposes. So here is the basic class that we will extend. It’ll hold the values for setting up the variables and will set user/password initially.

The file Structure:

  • class.Aloashbei.php
  • class.AloashbeiSMS.php
  • sms.php
  • includes/WebService_GP_ADP_BizTalk_SMS_Orchestrations.wsdl

Read the rest of this entry »

Grab your Google Buzz Status

Here’s how you can get your google buzz status with php. Just put your google username at the right place and do whatever you want.
We have used simpleXML to parse the google’s RSS feed for every user. :)

<?php
$user = "<username>";
$url = "http://buzz.googleapis.com/feeds/".$user."/public/posted";
$data = file_get_contents($url);
$xml = new SimpleXMLElement($data);

$status = $xml->entry[0]->summary;
$time = date('D j M Y g:i a', strtotime($xml->entry[0]->published));
echo "Status: $status <br />";
echo "Time: $time";
Tags: , , ,