PHP code example of rs / builder-api

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

    

rs / builder-api example snippets


$pendingRequest = BuilderApi::new();
$pendingRequest->forSite('sitename')
    ->withAuth('builderuser', 'key-123')
    ->unpublished()
    ->get('apiPages');

 $response = $pendingRequest->forSite('sitename')->get('apiPages', ['foo', 'bar']);

$response = BuilderApi::get('apiPages'); // returns BuilderResponse object

use RedSnapper\Builder\BuilderRequestFactory;

    public function __construct(BuilderRequestFactory $factory)
    {
        $this->factory = $factory;
        
        # or...
        $factory = app()->make(BuilderRequestFactory::class);
        
        $pendingRequest = $factory->new();
        $response = $pendingRequest->get('apiPages');
    }

 $data = $response->data(); # get json decoded data
 
 if($response->failed()) {
    $errorMsg = $response->errorMsg();
 }

$response->data();

$response->successful();

$response->failed();

$response->errorMsg(); # error msg provided by Builder

$response->status(); # status code of the response

$response->throw(); # throw an exception if a server or client error occurred

$response->getResponse(); # get the underlying 'Illuminate\Http\Client\Response' object
bash
php artisan vendor:publish --provider="RedSnapper\Builder\BuilderApiServiceProvider" --tag="config"
 php
# config/builder-api.php

return [
    'site'       => 'sitename',
    'published'  => true,
    'user'       => 'builderuser',
    'password'   => 'key-123',
];