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 :)

Github View Demo

22 thoughts on “Working with IDE One API

  1. Hi

    I cant seem to figure how to do this.

    I created a subdomain /ide then I added the code above to a .php file edit the username and password bit, but nothing seems to be working..

    Kindly help.
    Thank you.

  2. Thank you! It helped me a lot because I don’t understand how to communicate to Ideone API using SOAP protocol.

    Thank you.
    Happy new year 2012!

  3. Thanks a lot man! I got it working on my end.
    I used their api for our small class project.

    I don’t know ajax, so the result of the submission is posted on a separate page.

    Would you mind making the your example opensource? It’ll really help a lot!

    Thanks!

  4. your sample was very good sir. I really admire your work.
    thank you very much, it helped me understand the ideone api.
    thank you sir.

  5. Hello:
    Locate the files in the www folder and activate the php.ini localhost soap, but to run it shows me the following error:
    Something went wrong

    HELP!!!

  6. Hi.. My Final Projct is exactly yours ideone-compiler…
    pls help me in ths regard…. i dnt knw hw to use the projct of urs.. its nt compiln anythn to me.. wat chnges to b done to do it compile.. pls hlp..im in 11th hour…

  7. not a fun projct.. my Final Year Degree project.. mark oriented.. save me in ths aspect.. u did for c++, can i knw hw to do for “c”,,, sir need ur kind hlp

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>