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 π
[sourcecode language=”php”]
<?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 );
}
[/sourcecode]
Here is a working demo. It might be buggy, may be you could help me to find those bugs π
Sounds interesting. Will check it tonight. Thanks π
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.
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!
Hi could you pls guide me how to add ideone api to my website
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!
or at least, may you care to share your code for the process.php?
I really want to implement something just like in your example.
Thanks! π
Here you go https://github.com/tareq1988/ideone-compiler
Forked! Thanks a bunch π
Hello:
how could I pass these files to a MVC model?
Shanks
It’s not that difficult, you could wrap the code in a function and move it to a class.
help, I work with codeigniter ,:(
Fahim Murshed ! I need your email adress my friend .
From Turkey…
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.
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!!!
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…
It was a fun project and the source code is available on github. There is also the demo here. You shouldn’t have any problem.
urs is workn nw sir,, i need in “c” u did in c++,, can i get ur full support in my projct.. just for “c” alone sir
though its not working help me out yaar.
Sir i need for “C” alone… can u help me out in ths..
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
Change the
lang
to 11, it’ll work with C.[php]$lang = 11;[/php]
I need to implement this in MVC, please help
The code example is right here, so try to adapt it to MVC pattern. I can’t help more.
i was using api best before some time but it is not working now.
have ideone closed their server or service ??
Thanks for sharing us your work… it really helps me alot..
Hi,
I just wanna asked some help hope you wouldn’t mind. I tried you example demo above in my own local PC and it works some of it. But when i tried a simple structure code:
#include
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
it generates an compiler error info:
prog.cpp:6:3: error: stray β\β in program prog.cpp:6:12: warning: missing terminating " character [enabled by default] prog.cpp:6:3: error: missing terminating " character prog.cpp: In function βint main()β: prog.cpp:7:3: error: expected primary-expression before βreturnβ prog.cpp:7:3: error: expected β;β before βreturnβ
i do tried it also in your online demo http://wedevs.com/labs/compiler/ and it seems the same error occurred. Hope you could help me this one. thanks!
Thats a weird problem, I’ve also faced it. Not sure where is the bottleneck.
I also had that error but using stripslashes on code did it for me.
But the problem I am facing at the moment is that it is not working with an input. It returns 403.
I have downloaded your code and changed the username and pass to mine. When I tried it, it stops with “processing” part and i dont get any output. Help pls.
Hi Tareq! Pls help me. I did what you said in the comments but I dont know what is happening.
http://stackoverflow.com/q/18944839/2800050
I have posted my question in there. Hope you can help me. thanks a lot. π
hey ur program not showing any output . what to do?
Hi Mr Tareq,
I need a working code of IDEONE Api, the code which you provided in the github is throwing slash error in the code which i made of to compile But in your demo its working properly. Please me out to work this.
my mail id [email protected] Please send me the code of copy which is working properly.
regards
Prasanna
Can it be done using javascript?
Thanks it worked for me.You are awesome. Can I include it in my minor project? I’m making a Java tutorials website and needs online compiler.
Yes, you can include it. No problem!
Thank you sir! I used this on my project! I’ll include you in the reference π
i m getting an error: something went wrong
can you suggest me where such type of error can occur?