Working with IDE One API
I am very lazy to write any post. To be frank, I don’t find anything to write
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
<?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