Error when trying to fetch webhooks list in Shopify App

Error when trying to fetch webhooks list in Shopify App

cryptolikez
New Member
4 0 0

We are building our own custom app for the purpose of getting order information via orders webhook and then sending that order to a third party.
We are building it in PHP using Shopify's own PHP library 
We have successfully initialized.
However when we try to fetch current webhooks, we get this error:

 

Fatal error: Uncaught TypeError: Argument 1 passed to Shopify\Utils::loadCurrentSession() must be of the type array, null given, called in /www/doc/www.example.com/www/script/index.php on line 45 and defined in /www/doc/www.example.com/www/script/vendor/shopify/shopify-api/src/Utils.php:158 Stack trace: #0 /www/doc/www.example.com/www/script/index.php(45): Shopify\Utils::loadCurrentSession(NULL, NULL, NULL) #1 {main} thrown in /www/doc/www.example.com/www/script/vendor/shopify/shopify-api/src/Utils.php on line 158

 

By looking at our code below, can you tell us why this error occurs?

 

<?php

require("vendor/autoload.php");

use Shopify\Auth\FileSessionStorage;
use Shopify\Auth\Session;
use Shopify\Rest\Admin2022_10\Customer;
use Shopify\Rest\Admin2022_10\Webhookv2;
use Shopify\Utils;

Shopify\Context::initialize(
    'apiKey',
    'apiSecretKey',
    'read_analytics, read_assigned_fulfillment_orders, read_customers, read_draft_orders, read_merchant_managed_fulfillment_orders, read_order_edits, read_orders, read_script_tags, read_third_party_fulfillment_orders',
    'https://sozialstar.de/script/',
    new FileSessionStorage('/tmp/php_sessions'),
    '2022-10',
);

$this->test_session = Utils::loadCurrentSession(
    $requestHeaders,
    $requestCookies,
    $isOnline
);
Webhookv2::webhooks(
    $this->test_session, // Session
    [], // Url Ids
    [], // Params
);

?>
Replies 0 (0)