PHP code example of textalk / webshop-client

1. Go to this page and download the library: Download textalk/webshop-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

textalk / webshop-client example snippets




extalk\WebshopClient\Connection;

$api = Connection::getInstance('default', array('webshop' => 22222));

var_dump(
  $api->Articlegroup->list(
    array("name" => "sv", "uid" => true),
    array("limit" => 2)
  )
);

// Will produce:
// array(2) {
//   [0] =>
//   array(2) {
//     'name' =>
//     array(1) {
//       'sv' =>
//       string(4) "Herr"
//     }
//     'uid' =>
//     int(1347891)
//   }
//   [1] =>
//   array(2) {
//     'name' =>
//     array(1) {
//       'sv' =>
//       string(3) "Dam"
//     }
//     'uid' =>
//     int(1347897)
//   }
// }

$api = Connection::getInstance('default', array('webshop' => 22222));

// Save a handle to the API for a single Articlegroup:
$articlegroup = $api->Articlegroup(1347891);

// Get all names:
// These are all equivalent:
//
//  * $api->Articlegroup(1347891)->get('name')
//  * $api->Articlegroup->get(1347891, 'name')
//  * $api->call('Articlegroup.get', array(1347891, 'name'))
var_dump(
  $articlegroup->get('name')
);

// Will produce:
// array(1) {
//   'name' =>
//   array(2) {
//     'en' =>
//     string(3) "Men"
//     'sv' =>
//     string(4) "Herr"
//   }
// }

// This line won't actually DO anything, so it won't crasch:
$scissor = $api->IDontKnow("What I'm doing");

// But this will:
$scissor->run();

// -->
// PHP Fatal error:  Uncaught exception 'Textalk\WebshopClient\Exception\MethodNotFound' with message 'IDontKnow.run: Method not found: No API for IDontKnow
// On request: {"jsonrpc":"2.0","method":"IDontKnow.run","id":"7089b561-9252-4a0a-b45b-15a873509571","params":["What I'm doing"]}' in /home/liljegren/textalk-webshopclient-php/lib/Exception.php:32