None of the PHP API samples work?

rsirotarsirota Member Posts: 65

Am I missing something? I fill in the cluster, our key, secret and language. But nothing work. Are there any samples using the php API?

Tags:

Answers

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 722 moderator

    Hi @rsirota,

    Thank you for contacting us.

    Please check https://developers.lightspeedhq.com/ecom/introduction/php-client/ you need the WebshopappApiClient as well.

  • rsirotarsirota Member Posts: 65

    Here is what I am entering and things do not seem to want to work for me:

    <?php

    include_once 'src/WebshopappApiClient.php';


    //cluster_id is the location where the shop is hosted


    $api = new WebshopappApiClient('us1', 'myAPIKey', 'MyAPISecret

    ', 'en');


    $shopInfo = $api->shop->get();


    echo '<pre>';

    print_r($shopInfo);

    echo '</pre>';

    and here is what I get:

    Fatal error: Uncaught WebshopappApiException: Invalid login credentials. in /home/customer/www/sirota-consulting.com/public_html/PPLG/src/WebshopappApiClient.php:590 Stack trace: #0 /home/customer/www/sirota-consulting.com/public_html/PPLG/src/WebshopappApiClient.php(781): WebshopappApiClient->checkLoginCredentials() #1 /home/customer/www/sirota-consulting.com/public_html/PPLG/src/WebshopappApiClient.php(927): WebshopappApiClient->sendRequest('customers/count', 'get', Array) #2 /home/customer/www/sirota-consulting.com/public_html/PPLG/src/WebshopappApiClient.php(2504): WebshopappApiClient->read('customers/count', Array) #3 /home/customer/www/sirota-consulting.com/public_html/PPLG/eComTest.php(9): WebshopappApiResourceCustomers->count() #4 {main} thrown in /home/customer/www/sirota-consulting.com/public_html/PPLG/src/WebshopappApiClient.php on line 590

  • ricky1989ricky1989 Member Posts: 3

    You have to update this line:

    $api = new WebshopappApiClient('us1', 'myAPIKey', 'MyAPISecret', 'en');


    Change myAPIKey and MyAPISecret with the correct credentials. You can find them in your account.

  • rsirotarsirota Member Posts: 65

    I just put that in for this use, I have the real numbers in place...

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 722 moderator

    Hi @rsirota,

    Are you sure you're using the correct key and secret? I see you've posted a few things about the Retail API. These are different API's and need a different way to connect.

    Can you share only your key?

  • rsirotarsirota Member Posts: 65

    I got it all working, it was a copy and paste error the key had a carriage return in it.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 722 moderator

    Okay perfect.

Sign In or Register to comment.