ohshopify.php,undefined session vars&其他未定义的变量

时间:2012-11-30 07:17:36

标签: php session shopify

我无法从ohShopify.php PHP JSON客户端获得所需的结果。

请原谅我,因为我是php等人的新手,但会尽可能清楚地解释我的问题。

我不确定这些相关信息,但我在Windows 7 Pro 64bit上使用WAMP和PHP 5.3.13。

这是我的index.php

require 'shopify.php';
$api_key    = '---';
$secret = '---';
$scope      = read_products;

if (isset($_GET['code'])) { 

    $shopifyClient = new ShopifyClient($_GET['shop'], "", $api_key, $secret);
    session_unset();


    $_SESSION['token'] = $shopifyClient->getAccessToken($_GET['code']);
    if ($_SESSION['token'] != '')
        $_SESSION['shop'] = $_GET['shop'];

    header("Location: store.php");
    exit;   

} else {    

    $shop = '---.shopify.com';
    $shopifyClient = new ShopifyClient($shop, "", $api_key, $secret);

    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }

    header("Location: " . $shopifyClient->getAuthorizeUrl($scope, $pageURL));
    exit;
}

成功时将位置设置为store.php:

require 'shopify.php';

$sc = new ShopifyClient($_SESSION['shop'], $_SESSION['token'], $api_key, $secret);

try
{
    // Get all products
    $products = $sc->call('GET', '/admin/products.json', array('published_status'=>'published'));




}
catch (ShopifyApiException $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

    */
}
catch (ShopifyCurlException $e)
{
    // $e->getMessage() returns value of curl_errno() and $e->getCode() returns value of curl_ error()
}

这是我遇到错误的地方。没有设置任何变量。 $ _SESSION,$ api_key和$ secret都回来了“未定义”。

Screenshot

我猜我错过了一些东西,但一直在找几个小时而且无法理解。 $ _SESSION如何被定义,因为它是一个“超全球”变量。

如果我能提供更多信息,请告诉我。提前谢谢。

0 个答案:

没有答案