PHP code example of garmanio / laravel-shopify

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

    

garmanio / laravel-shopify example snippets


$sh->installURL(['permissions' => array('write_orders', 'write_products')]);

$code = Input::get('code');
$sh = App::make('ShopifyAPI', ['API_KEY' => '', 'API_SECRET' => '', 'SHOP_DOMAIN' => '']);

try
{
	$accessToken = $sh->getAccessToken($code);
}
catch (Exception $e)
{
	echo '<pre>Error: ' . $e->getMessage() . '</pre>';
}

// Save $accessToken

try
{

	$call = $sh->call(['URL' => 'products.json', 'METHOD' => 'GET', 'DATA' => ['limit' => 5, 'published_status' => 'any']]);
}
catch (Exception $e)
{
	$call = $e->getMessage();
}

echo '<pre>';
var_dump($call);
echo '</pre>';


$testData = ['name' => 'Foo', 'location' => 'Bar'];
$view = (string) View::make('snippet', $testData);

$themeID = 12345678;

try
{
	$call = $sh->call(['URL' => '/admin/themes/' . $themeID . '/assets.json', 'METHOD' => 'PUT', 'DATA' => ['asset' => ['key' => 'snippets/test.liquid', 'value' => $view] ] ]);
}
catch (Exception $e)
{
	$call = $e->getMessage();
}

echo '<pre>';
var_dump($call);
echo '</pre>';