vipinkhushu/hackerearth-sdk-php

使用 HackerEarth API V3 运行和编译代码的 PHP SDK

dev-master 2016-01-25 16:51 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:38:44 UTC


README

使用 HackerEarth API V3 运行和编译代码的 PHP SDK

这个库可以帮助您使用 HackerEarth API v3 编译和运行您的代码

使用 HackerEarth API,您可以使用他们的 CodeTable 编译和运行您的代码

先决条件

您需要从 HackerEarth Here 获取您的客户端密钥,然后您就完成了!

安装

目前您可以简单下载此存储库的 ZIP 文件,并将其放入您的代码中:require_once DIR.'path\to\folder\sdk\index.php';

通过 Composer 使用

composer require vipinkhushu/hackerearth-sdk-php
require_once __DIR__.'\sdk\index.php';

语言代码

请仅使用以下代码来提供语言名称:C, CPP, CPP11, CLOJURE, CSHARP, JAVA, JAVASCRIPT, HASKELL, PERL, PHP, PYTHON, RUBY

设置

//Import the SDK 
require_once __DIR__.'path\sdk\index.php';

//Setting up the Hackerearth API
$hackerearth = Array(
		'client_secret' => 'b1803e335e227a1320fc6dc3587a0d496e97d3e5', //(REQUIRED) Obtain this by registering your app at http://www.hackerearth.com/api/register/
        'time_limit' => '5',   //(OPTIONAL) Time Limit (MAX = 5 seconds )
        'memory_limit' => '262144'  //(OPTIONAL) Memory Limit (MAX = 262144 [256 MB])
	);


编译您的代码

//compile your code 
//Feeding Data Into Hackerearth API
$config = Array();
$config['time']='5';	 	//(OPTIONAL) Your time limit in integer and in unit seconds
$config['memory']='262144'; //(OPTIONAL) Your memory limit in integer and in unit kb
$config['source']='print("Hello! Vipin");';    	//(REQUIRED) Your source code for which you want to use hackerEarth api
$config['input']='';     	//(OPTIONAL) Input against which you have to test your source code
$config['language']='PYTHON';   	//(REQUIRED) Choose any one of them 
						 	// C, CPP, CPP11, CLOJURE, CSHARP, JAVA, JAVASCRIPT, HASKELL, PERL, PHP, PYTHON, RUBY

//Sending request to the API to compile and run and record JSON responses
$responseOfCompile = compile($hackerearth,$config);

运行您的代码

//Run a source code against a input
//Feeding Data Into Hackerearth API
$config = Array();
$config['time']='5';	 	//(OPTIONAL) Your time limit in integer and in unit seconds
$config['memory']='262144'; //(OPTIONAL) Your memory limit in integer and in unit kb
$config['source']='print("Hello! Vipin");';    	//(REQUIRED) Your source code for which you want to use hackerEarth api
$config['input']='';     	//(OPTIONAL) Input against which you have to test your source code
$config['language']='PYTHON';   	//(REQUIRED) Choose any one of them 
						 	// C, CPP, CPP11, CLOJURE, CSHARP, JAVA, JAVASCRIPT, HASKELL, PERL, PHP, PYTHON, RUBY
$responseOfRun = run($hackerearth,$config);

编译您的文件

//compile your code  from a file
//Feeding Data Into Hackerearth API
$config = Array();
$config['time']='5';	 	//(OPTIONAL) Your time limit in integer and in unit seconds
$config['memory']='262144'; //(OPTIONAL) Your memory limit in integer and in unit kb
$config['file']='';			//(REQUIRED WHEN YOU ARE USING A SOURCE FILE) Give the complete address to the file
$config['input']='';     	//(OPTIONAL) Properly Formatted Input against which you have to test your source code
$config['language']='PYTHON';   //(REQUIRED) Choose any one of the below
						 	// C, CPP, CPP11, CLOJURE, CSHARP, JAVA, JAVASCRIPT, HASKELL, PERL, PHP, PYTHON, RUBY


//Sending request to the API to compile and run and record JSON responses
$response = compile_with_file($hackerearth,$config); 

运行您的文件

//Run a source code against a input   from a file
//Feeding Data Into Hackerearth API
//Feeding Data Into Hackerearth API
$config = Array();
$config['time']='5';	 	//(OPTIONAL) Your time limit in integer and in unit seconds
$config['memory']='262144'; //(OPTIONAL) Your memory limit in integer and in unit kb
$config['file']='';			//(REQUIRED WHEN YOU ARE USING A SOURCE FILE) Give the complete address to the file
$config['input']='';     	//(OPTIONAL) Properly Formatted Input against which you have to test your source code
$config['language']='PYTHON';   //(REQUIRED) Choose any one of the below
						 	// C, CPP, CPP11, CLOJURE, CSHARP, JAVA, JAVASCRIPT, HASKELL, PERL, PHP, PYTHON, RUBY


//Sending request to the API to compile and run and record JSON responses
$response = run_with_file($hackerearth,$config);

许可协议

MIT