如何使用Sphere Engine API检查我的代码?

时间:2015-10-09 10:38:58

标签: api rest

来自http://sphere-engine.com/services/problems

发送请求 按照向服务发送请求的示例:

curl -H "Content-Type: application/json" -X POST
-d '{
    "code":"EXDOC"
    "compilerId":"11",
    "source":"#include<stdio.h> int main(){ // empty solution }"
    }'
"https://problems.sphere-engine.com/api/v3/submissions?access_token=xxxxxx"

我创建了一个名为HELLO_WORLD的问题但是当我发送问题的帖子请求时我得到了

{"message":"Forbidden","data":[]}

我已检查过我的访问令牌是否正确,因为它适用于其他来电。

2 个答案:

答案 0 :(得分:0)

$token = '***********';
$get_submission_id = curl_init();   

curl_setopt_array($get_submission_id, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://api.compilers.sphere-engine.com/api/v3/submissions?access_token=*******',
CURLOPT_USERAGENT => 'Codular Sample cURL Request',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
    language => $lang,
    input => $input,
    sourceCode => $code
)
)); 

$get_ideone_results = curl_init();

$submissions_id =  $results->id;

$url = 'http://api.compilers.sphere-engine.com/api/v3/submissions/'.$submissions_id.'/?access_token=***********&withSource=1&withInput=1&withOutput=1&withStderr=1&withCmpinfo=1';

usleep(2000000);

$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);

echo $data;

请仔细检查代码并分享您的想法

答案 1 :(得分:0)

我认为这是因为问题代码(EXDOC)不存在。尝试创建一个新问题并使用其问题代码