Error when trying to fetch webhooks list in Shopify App built in PHP

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 2 (2)

ShopifyDevSup
Shopify Staff
1312 215 454

Hey @cryptolikez

After some investigating we noticed a similar issue opened in the GitHub Repo for the PHP library here. I am not sure if it was you who opened that issue, but at the moment this is the best place to bring questions, discuss unexpected behaviors, and provide feedback about our API Libraries. It looks like there is now a reply in that issue, and we would suggest engaging and sharing any other details, findings, or question in the issue thread. 

Cheers!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

cryptolikez
New Member
4 0 0

Thanks for nothing. I will complain.