Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify PHP SDK Docs Example gives Syntax error: unexpected token '{'PHP #303

Closed
khanakia opened this issue Oct 11, 2023 · 3 comments
Closed
Labels

Comments

@khanakia
Copy link

Issue summary

Write a short description of the issue here ↓
I am using the PHP Example from here https://shopify.dev/docs/api/admin-rest#endpoints

$productId = "11235813213455"
// `session` is built as part of the OAuth process
$client = new Shopify\Clients\Rest(
    $session->getShop(),
    $session->getAccessToken()
);

// GIVES ERROR
$response = $client->get({
    path: "products/$productId",
    query: ["id" => 1, "title" => "title"]
});

Expected behavior

What do you think should happen?
The above code example provided by Shopify Docs should work

Actual behavior

What actually happens?

   ParseError 

  syntax error, unexpected token "{"

  at app/Console/Commands/Test.php:140
    136▕         );
    137▕         // $response = $client->get('shop');
    138▕ 
    139▕ 
  ➜ 140▕         $response = $client->get({
    141▕             path: "products/$productId",
    142▕             query: ["id" => 1, "title" => "title"]
    143▕         });
    144▕         dd($response->getDecodedBody());

      +1 vendor frames 
@xavier-mejia
Copy link

The Shopify documentation is unfortunately not very helpful. This example that they provide has syntax errors. Here's how it's supposed to be written:

$productId = "11235813213455";
// `session` is built as part of the OAuth process
$client = new Shopify\Clients\Rest(
    $session->getShop(),
    $session->getAccessToken()
);

// not using braces{} when using $client->get()
$response = $client->get(
    path: "products/$productId",
    query: ["id" => 1, "title" => "title"]
);

Hope this helps!

Copy link

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Dec 16, 2023
Copy link

github-actions bot commented Jan 1, 2024

We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants