PHP code example of almesery / laravel-foodics

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

    

almesery / laravel-foodics example snippets


return [

    "foodics_mode" => env("FOODICS_MODE", "sandbox"),

    "client_id" => env("FOODICS_CLIENT_ID", null),

    "client_secret" => env("FOODICS_CLIENT_SECRET", null),

    "redirect_uri" => env("FOODICS_REDIRECT_URI", null),

    "webhook_url" => env("FOODICS_WEBHOOK_URL", null)
    
];

    
    use Foodics\Services\FoodicsRedirectServices;
    
    $foodicsOAuthServices = new FoodicsRedirectServices();
    
    return $foodicsOAuthServices->redirect();
    
    // you will redirect to [FOODICS_REDIRECT_URI], the url contain code as a query parameter

    
   use Foodics\Services\FoodicsAuthorizationServices;
    
   $foodicsAuthorizationServices = new FoodicsAuthorizationServices();
   
   // $code variable you can get from the previous request 
   $response =  $foodicsOAuthServices->authorize($code);
   
   $access_token = $response["access_token"];

    
   use Foodics\Foodics;
    
   $foodics = new Foodics($access_token);
    
   $data = $foodics->settings()->whoami();
   
   echo $data;
bash
php artisan vendor:publish --provider="Foodics\FoodicsServiceProvider"