1. Go to this page and download the library: Download nandung/copilot-proxy 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/ */
nandung / copilot-proxy example snippets
use Nandung\CopilotProxy\CopilotProxy;
// Get device code
$auth = CopilotProxy::auth();
$deviceCode = $auth->getDeviceCode();
echo "Go to: {$deviceCode->verificationUri}\n";
echo "Enter code: {$deviceCode->userCode}\n";
// Wait for user to authorize (polls automatically)
$githubToken = $auth->pollAccessToken($deviceCode, function($attempt, $max) {
echo "Waiting for authorization... ({$attempt}/{$max})\n";
});
// Save token for later use
file_put_contents('github_token.txt', $githubToken);
echo "Token saved!\n";
use Nandung\CopilotProxy\CopilotProxy;
$proxy = new CopilotProxy(file_get_contents('github_token.txt'));
// Simple question
$answer = $proxy->ask('What is the capital of France?');
echo $answer; // Paris
// Get user info
$user = $proxy->getUser();
echo "Logged in as: {$user['login']}\n";
// In AppServiceProvider
use Nandung\CopilotProxy\CopilotProxy;
public function register()
{
$this->app->singleton(CopilotProxy::class, function () {
return new CopilotProxy(config('services.copilot.token'));
});
}
// Usage in controller
public function index(CopilotProxy $proxy)
{
return $proxy->ask('Hello!');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.