PHP code example of terentev-space / kithook-php
1. Go to this page and download the library: Download terentev-space/kithook-php 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/ */
terentev-space / kithook-php example snippets
$yourWebhookUri = 'https://example.com';
$yourWebhookId = 'myId-123';
$yourElseContentType = 'application/xml';
// Json
$yourWebhookJsonData = [
'anything'
];
// Form
$yourWebhookFormData = [
'param1' => 'value1',
];
// Query
$yourWebhookQueryData = [
'param1' => 'value1',
];
// Xml
$yourWebhookXmlData = <<<XML
<?xml version="1.0" encoding="UTF-8"
/** @var \KitHook\Interfaces\ClientInterface|\KitHook\Adapter $client **/
// Simple HTTP Put Json
$client->sendHttpPutJson($yourWebhookUri, $yourWebhookJsonData, $yourWebhookId);
// Simple HTTP Post Form
$client->sendHttpPostForm($yourWebhookUri, $yourWebhookFormData, $yourWebhookId);
// Simple HTTP Get Query
$client->sendHttpGetEmpty($yourWebhookUri . '?' . http_build_query($yourWebhookQueryData), $yourWebhookId);
// Build
$content = $client->contentBuilder()->makeHttp()
// OR
->withType(\KitHook\Entities\Messages\Contents\QueueHttpMessageContent::TYPE_ELSE)
->withData($yourWebhookXmlData)
->withFormatForElseType($yourElseContentType)
// OR
->fillElse($yourWebhookXmlData, $yourElseContentType)
// FINALLY
->build();
$message = $client->messageBuilder()->makeHttp()
// OR
->withId($yourWebhookId)
->withUri($yourWebhookUri)
->withMethod(\KitHook\Entities\Messages\QueueHttpMessage::METHOD_POST)
->withContent($content)
// OR
->fillPost($yourWebhookUri, $yourWebhookId, $content, [/* headers */], [/* properties */])
// OR
->fillPost($yourWebhookUri, $yourWebhookId)
->makeContent()
->fillForm($yourWebhookFormData)
->buildFromMessage()
// FINALLY
->build();
$client->send($message);
bash
$ composer
bash
$ composer