Example #1
0
 public function __construct($shop_domain, $token, $api_key, $secret)
 {
     $this->shop_domain = $shop_domain;
     $this->token = $token;
     $this->api_key = $api_key;
     $this->secret = $secret;
     parent::__construct($shop_domain, $token, $api_key, $secret);
 }
 public function __construct($shop_domain, $token, $api_key, $secret)
 {
     parent::__construct($shop_domain, $token, $api_key, $secret);
 }
Example #3
0
<?php

// echo "signature: " . $_GET['signature'];
require __DIR__ . '/BizwebApi/BizwebClient.php';
session_start();
define("BIZWEB_API_KEY", "");
define("BIZWEB_SECRET", "");
// nono: $_SESSION['shop']
// ok: $_SESSION['token']
$sc = new BizwebClient('nguyenduyphong.bizwebvietnam.net', '4548228799e840608cf3f0eff1cab9da', BIZWEB_API_KEY, BIZWEB_SECRET);
// var_dump($_SESSION);
try {
    // Get all products
    $products = $sc->call('GET', '/admin/store.json?page=1', array());
    // NOT shop.json
    echo "shop: " . $_SESSION['shop'];
    echo "<br/>token: " . $_SESSION['token'];
    echo "<br/>";
    echo "<pre>";
    var_dump($products);
    echo "</pre>";
} catch (BizwebApiException $e) {
    var_dump($e);
    /* 
             $e->getMethod() -> http method (GET, POST, PUT, DELETE)
             $e->getPath() -> path of failing request
             $e->getResponseHeaders() -> actually response headers from failing request
             $e->getResponse() -> curl response object
             $e->getParams() -> optional data that may have been passed that caused the failure
    */
}
Example #4
0
    // die( "signature: " . $_GET['signature']);
    // Now, request the token and store it in your session.
    $token = $shopifyClient->getAccessToken($_GET['code'], REDIRECT_URI);
    $_SESSION['token'] = $token;
    if ($_SESSION['token'] != '') {
        $_SESSION['shop'] = $_GET['shop'];
    }
    echo $token;
    header("Location: shop.php");
    exit;
} else {
    if (isset($_POST['shop']) || isset($_GET['shop'])) {
        // Step 1: get the shopname from the user and redirect the user to the
        // shopify authorization page where they can choose to authorize this app
        $shop = isset($_POST['shop']) ? $_POST['shop'] : $_GET['shop'];
        $shopifyClient = new BizwebClient($shop, "", BIZWEB_API_KEY, BIZWEB_SECRET);
        // if(!$shopifyClient->validateSignature($_GET)) die('Error: invalid signature.');
        // redirect to authorize url
        header("Location: " . $shopifyClient->getAuthorizeUrl(BIZWEB_SCOPE, REDIRECT_URI));
        exit;
    }
}
// first time to the page, show the form below
?>
    <p>Install this app in a shop to get access to its private admin data.</p> 

    <p style="padding-bottom: 1em;">
        <span class="hint">Don&rsquo;t have a shop to install your app in handy? <a href="https://app.shopify.com/services/partners/dev_shops/new">Create a test shop.</a></span>
    </p> 

    <form action="" method="post">