PHP code example of musheabdulhakim / gohighlevel-php

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

    

musheabdulhakim / gohighlevel-php example snippets


use MusheAbdulHakim\GoHighLevel\GoHighLevel;

// Initialize the client with your API key
$client = GoHighLevel::client('ACCESS_TOKEN');

// Example: Get a business by its ID
$businessId = 'your_business_id_here';
$businessData = $client->businesses()->get($businessId);

print_r($businessData);

use MusheAbdulHakim\GoHighLevel\GoHighLevel;
use GuzzleHttp\Client as GuzzleClient;

$client = GoHighLevel::factory()
    ->withApiKey('YOUR_API_KEY')
    // Set a custom base URI (optional)
    ->withBaseUri('https://custom-api-endpoint.com')
    // Set the API Version (optional)
    ->withVersion('2024-05-15')
    // Use a custom PSR-18 HTTP client (optional)
    ->withHttpClient(new GuzzleClient())
    ->make();

// Now you can use the fully configured client
$contacts = $client->contacts()->all();

use MusheAbdulHakim\GoHighLevel\GoHighLevel;

$params = [
    'grant_type' => 'authorization_code',
    'client_id' => 'YOUR_CLIENT_ID',
    'client_secret' => 'YOUR_CLIENT_SECRET',
    'redirect_uri' => 'YOUR_REDIRECT_URI',
    'code' => 'THE_AUTH_CODE_FROM_GOHIGHLEVEL',
];

$accessTokenResponse = GoHighLevel::getAccessToken(
    'https://services.leadconnectorhq.com/oauth/token',
    'application/x-www-form-urlencoded',
    $params
);

print_r($accessTokenResponse);
bash
composer 
bash
git clone https://github.com/MusheAbdulHakim/gohighlevel-php-sdk.git

cd gohighlevel-php