PHP code example of mennen-online / simple-api-connector
1. Go to this page and download the library: Download mennen-online/simple-api-connector 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/ */
mennen-online / simple-api-connector example snippets
return [
'fallback_response_model' => \MennenOnline\SimpleApiConnector\Models\BaseResponseModel::class,
'base_url' => 'https://example.com/api',
'authentication' => [
'type' => 'basic', // basic, bearer, token, digest, client_credentials
'username' => '', //use for basic and digest
'password' => '', //use for basic and digest
'token' => '', //use for bearer and token
'client_id' => '', //use for client_credentials
'client_secret' => '', //use for client_credentials
'authentication_url' => '' //use for client_credentials
],
'endpoints' => [
'categories' => '/categories',
'products' => '/products',
'users/:id' => '/users/:id',
'users/:user_id/orders/:order_id' => '/users/:user_id/orders/:order_id
],
'response_models' => [
'categories' => 'Model::class', //Response model for Categories
'products' => 'Model::class', //Response model for Products
]
$connector = new \MennenOnline\SimpleApiConnector\Connector\ApiConnector('my-shopware6-shop');
// To Call the API use the following code:
// GET
$response = $connector->get('categories');
// POST
$response = $connector->post('categories', ['name' => 'My Category']);
// PUT
$response = $connector->put('categories/1', ['name' => 'My Category']);
// DELETE
$response = $connector->delete('categories/1');
// To use URLs with names ID
$response = $connector->get('users/:id', [':id' => 1]);
// To use URLs with multiple names ID
$response = $connector->get('users/:user_id/orders/:order_id', [':user_id' => 1, ':order_id' => 1]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.