PHP code example of stackapi / stackapi-php

1. Go to this page and download the library: Download stackapi/stackapi-php 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/ */

    

stackapi / stackapi-php example snippets



StackApi\StackApi;

$stackapi = new StackApi(getenv('STACKAPI_SECRET_KEY'), getenv('STACKAPI_PUBLIC_KEY'));

$sms = $stackapi->notifications->sendSms(['to' => '08031234567', 'message' => 'Your code is 123456']);
echo $sms['status'];

use StackApi\Webhook;
use StackApi\WebhookVerificationException;

try {
    $event = Webhook::verify(file_get_contents('php://input'), getallheaders(), getenv('STACKAPI_WEBHOOK_SECRET'));
} catch (WebhookVerificationException $e) {
    http_response_code(400);
    exit;
}
bash
composer