Notice: We've implemented a new Partners and Developers board structure and moved content into the new structure. To find your previously submitted topics and replies click on your avatar in the top right followed by My Profile.

Official PHP Client Library Authentication code

BartLeuven
Visitor
1 0 0

I have a partner account and created a store to do some testing. Made a private app, generated the necessary keys etc to get started. I know how to use the REST requests together with curl and it works fine. But now I'd like to use the (official) PHP client library, which I installed with composer. I find alot of tutorials and explanations about authentication, but it seems hard to find actual sample code on how to do this. This is what I have so far (I found this online), but of course it returns errors about vars not found (cfr headers and such). 

 

 

 

 

include('vendor/autoload.php');
use Shopify\Clients\Rest;
$session = Shopify\Utils::loadCurrentSession($headers, $cookies, $isOnline);
$client = new Rest($session->getShop(), $session->getAccessToken());
$response = $client->get('shop');

 

 

 

 

Once authenticated I'll know my way around; but I don't seem to get beyond this point ...
Any sample code with (fake) credentials and such would be much appreciated.
Thnx in advance.

Replies 2 (2)

Mammouth
Tourist
15 0 2

Did you found how ?

 

I'm currently stuck with

 

$requestHeaders = array(
'api_version' => '2023-04',
'X-Shopify-Access-Token' => $accessToken
);

$requestCookies = array();
$isOnline = true;

$session = Shopify\Utils::loadCurrentSession(
$requestHeaders,
$requestCookies,
$isOnline
);

 

returning Missing Authorization key in headers

achintha
Shopify Partner
5 0 0

Did you able to find how it is doing?