1

ohShopify.php PHP JSON クライアントから目的の結果を得ることができません。

私はphpなどにまったく慣れていないので、私を許してください。しかし、私の問題をできるだけ明確に説明しようとします。

この関連情報かどうかはわかりませんが、Windows 7 Pro 64bit で PHP 5.3.13 で WAMP を使用しています。

これが私の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;
}

成功すると、場所が my 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 はすべて「未定義」で返されます。

スクリーンショット

私は何かが欠けていると推測していますが、何時間も探していて、それを理解できません。$_SESSION は「スーパーグローバル」変数であるため、どのように未定義にできますか。

他に提供できる情報があれば、お知らせください。前もって感謝します。

4

0 に答える 0