Why isn't the Shopify PHP API library functioning properly?

Solved

Why isn't the Shopify PHP API library functioning properly?

Ohed007
Shopify Partner
4 0 1

Hi All,

 

I have cloned https://github.com/Shopify/shopify-php-api and setup everything on local repo but when trying to call any API using some code, getting class file error Fatal error: Uncaught Error: Class "Shopify\Context" not found in E:\xamp\htdocs\ShopifyApp\shopify-php-api-official\CreateOrder.php:11
 
Below is the code on my page:

use Shopify\Clients\Rest;
use Shopify\Context;
use Shopify\Auth\FileSessionStorage;

Shopify\Context::initialize('APIKey', 'Secretey', 'write_assigned_fulfillment_orders, read_assigned_fulfillment_orders, write_customers, read_customers, write_discounts, read_discounts, write_draft_orders, read_draft_orders, write_files, read_files, write_fulfillments, read_fulfillments, write_gift_cards, read_gift_cards, write_inventory, read_inventory, write_order_edits, read_order_edits, write_orders, read_orders, write_payment_terms, read_payment_terms, write_price_rules, read_price_rules, write_product_listings, read_product_listings, write_products, read_products, write_reports, read_reports, write_script_tags, read_script_tags, write_shipping, read_shipping', 'store.myshopify.com', new FileSessionStorage('/tmp/php_sessions'), '2022-01');
$accessToken = 'AccessToken';

$client = new Rest("store", $accessToken);
$response = $client->get(
"/admin/oauth/access_scopes.json"
);

print_r($response);

Can you please guide me here so that I use the php library for custom App as private App is no longer exist. I tried to create the custom app from store itself.

Thanks in advance

Accepted Solution (1)

Rajat0022
Shopify Partner
1 1 1

This is an accepted solution.

Hey did you add at beginning of file ?
require_once('vendor/autoload.php');

View solution in original post

Replies 2 (2)

Rajat0022
Shopify Partner
1 1 1

This is an accepted solution.

Hey did you add at beginning of file ?
require_once('vendor/autoload.php');

parthgoyani
Shopify Partner
6 0 0

I have the same problem.
Can you help me?


Screenshot at Jul 19 12-02-54.png

Shopify Expert