pushandmotion / pamsdk-php
There is no license information available for the latest version (dev-master) of this package.
PAM PHP client.
dev-master
2018-08-08 05:16 UTC
Requires
- php: >=5.5.9
- ext-curl: *
- defuse/php-encryption: ^2.1
- mcustiel/php-simple-di: >=1.2.0
- php-curl-class/php-curl-class: ^7.3
- php-di/php-di: ^5.4
- psr/log: ~1.0
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: 5.7
- raveren/kint: ~0.9
This package is not auto-updated.
Last update: 2020-10-11 12:53:16 UTC
README
Clien SDK to access PAM
Requirements
- PHP 5.6.0+
Installation
-
Include the library via Composer
$ composer require pushandmotion/pamsdk-php:dev-master
-
Include the Composer autoloader:
require __DIR__ . '/vendor/autoload.php';
Usage
Install PAM script (Track page view)
-
Create PAM Script from your backend code and echo it into HTML just before the
</body>
tag$baseUrl = 'https://<your-pam-website>.com'; $username = '<your-username>'; $password = '<your-password>'; $appId = '<your-app-id>'; $secret = '<your-app-secret>'; $sdk = new \PAM\Sdk($baseUrl, $username, $password, $appId, $secret); $pamScript = $sdk->createTrackingScript( [ 'field-1' => 'value-1', 'field-2' => 'value-2', 'field-N' => 'value-N', 'content-tags' => $sdk->createTags(['content-tag1','content-tag2']) ]);
-
If you use some kind of MVC framework so in your view should have something like this (the actual code will depends on your framework)
<html> <body> <h1>Hello, PAM</h1> {!! $pamScript !!} </body> </html>
-
After install the script in HTML page then verify the script by inspecting the network request from your browser when load page; you will see the POST request /event call with JSON response id and sid
Make Form Submit
When you receive form submission from your website, you can forward those form data to PAM by calling submitForm method
$result = $sdk->submitForm( '1', //formId must match the formId received from PAM backend [ 'param-1' => 'value-1', 'param-2' => 'value-2', ... 'param-N' => 'value-N' ]);