PHP code example of nahid / envato-php

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

    

nahid / envato-php example snippets


Nahid\EnvatoPHP\EnvatoServiceProvider::class,

'Envato' => Nahid\EnvatoPHP\Facades\Envato::class,

return [
    "client_id"     => 'envato_app_client_id',

    'client_secret' => 'envato_app_client_secret',

    "redirect_uri"  =>  'redirect_uri',
    
     'app_name'      => 'nahid-envato-app',
];

use Nahid\EnvatoPHP\Envato;

$config = [
            "client_id"     => 'envato_app_client_id',
        
            'client_secret' => 'envato_app_client_secret',
        
            "redirect_uri"  =>  'redirect_uri',
            
             'app_name'      => 'nahid-envato-app',
        ];
        
 
 $envato = new Envato($config);
 
 $user = $envato->me()->accounts();
 
 var_dump($user->data);
 

 use Nahid\EnvatoPHP\Facades\Envato;
 
 $user = Envato::me()->accounts();
 dd($user->data);
 

 // For envato purchase code verify  
 
 use Nahid\EnvatoPHP\Facades\Envato;
 
 $purchaseCode = 'purchase_code_here';
 $purchaseVerify = Envato::me()->sale($purchaseCode);
 if($purchaseVerify->getStatusCode() == 200) {
    dd($purchaseVerify->data);
 } else {
    dd("Invalid Purchase Code");
 }
 
shell
composer 
shell
php artisan vendor:publish --provider="Nahid\EnvatoPHP\EnvatoServiceProvider"