PHP code example of shipu / hackerrank-api

1. Go to this page and download the library: Download shipu/hackerrank-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shipu / hackerrank-api example snippets


Shipu\HackerRank\HackerRankServiceProvider::class,

'HackerRank' => Shipu\HackerRank\Facades\HackerRank::class,

return [
    /*
    |--------------------------------------------------------------------------
    | HackerRank API KEY
    |--------------------------------------------------------------------------
    |
    | https://www.hackerrank.com/api/
    |
    */

    'api_key' => env('HACKERRANK_API_KEY', 'YOUR_HACKER_RANK_API_KEY'),
];

use Shipu\HackerRank\HackerRank;

$config = [
            "api_key"     => 'hackerrank_app_key',
        ];
        
 
 $hackerRank = new HackerRank($config);
 
 $allLanguages = $hackerRank->checker()->languages();
 
 var_dump($allLanguages->data);
 

 use Shipu\HackerRank\Facades\HackerRank;
 //..
 //..
 $allLanguages = HackerRank::checker()->languages();
 
 dd($allLanguages->data);
 

 use Shipu\HackerRank\Facades\HackerRank;
 //..
 //..
$response = HackerRank::checker()->submission('php', ' echo "It's Working"; 

  use Shipu\HackerRank\Facades\HackerRank;
  //..
  //..
  // Problem is returns the sum of two integers.
  // Problem link: https://www.hackerrank.com/challenges/solve-me-first
  // Submit code with two tescase example.
  
 $response = HackerRank::checker()->submission('php', '
                 function solveMeFirst($a,$b){
                   return $a+$b;
                 }
                 $handle = fopen ("php://stdin","r");
                 $_a = fgets($handle);
                 $_b = fgets($handle);
                 $sum = solveMeFirst((int)$_a,(int)$_b);
                 print ($sum);
                 fclose($handle);
             

php artisan vendor:publish --provider="Shipu\HackerRank\HackerRankServiceProvider"