public function test_validateProxy() { $shopify = new \cdyweb\Shopify\Shopify(json_decode(json_encode(array('shopname' => 'unit-test', 'scope' => array('read', 'write'), 'client_id' => 'foo', 'client_secret' => 'hush', 'redirect_uri' => 'http://baz')))); $query_string = "extra=1&extra=2&shop=shop-name.myshopify.com&path_prefix=%2Fapps%2Fawesome_reviews×tamp=1317327555&signature=a9718877bea71c2484f91608a7eaea1532bdf71f5c56825065fa4ccabe549ef3"; $result = $shopify->validateProxy($query_string); $this->assertEquals(true, $result); }
{ } class Customer extends \cdyweb\Shopify\Model\AbstractModel { } //load config $config = array(); if (file_exists('config.json')) { $config = json_decode(file_get_contents('config.json')); } //connect to database $pdo = new PDO('mysql:host=localhost;dbname=test', 'test', ''); //create a database token storage $tokenStorage = new \cdyweb\Shopify\OAuth\PDOTokenStorage($pdo); //create the Shopify API client $client = new \cdyweb\Shopify\Shopify($config, $tokenStorage); //if the request is a shopify callback, a temporary "code" is provided in the query string if (isset($_GET['code'])) { //finalize the oauth process by requesting a permanent access token $client->authorizeCallback(); //reload this page header('HTTP/1.1 302 Found'); header('Location: ' . $config['redirect_uri']); exit; } //if we haven't connected to Shopify yet, let's redirect to the Authorize page if (!$client->hasAccessToken()) { header('HTTP/1.1 302 Found'); header('Location: ' . $client->getAuthorizeUri()); exit; }