Download the PHP package mltpss/php-sdk without Composer
On this page you can find all versions of the php package mltpss/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-sdk
Multipass - PHP SDK
Requirements
This SDK has been tested with PHP 5.5 and greater.
We are unable to provide official support for earlier versions. For more information about end of life PHP branches, see this page.
Install
This package is intended for custom PHP websites and advanced integrations.
If you're using WordPress, we've made it easy for you. Download the SQweb plugin directly from WordPress.org, or check out the source.
Recommended : Composer + dotenv
-
In your project root, execute
composer require mltpss/php-sdk
. -
Create a
.env
file at the root of your project, or edit it if you already have one. -
In
.env
, paste the following configuration:Change
SQW_ID_SITE
with your website ID andSQW_SITENAME
with the name to show on the large Multipass button.
For additional settings, see "Options" below.
Composer + Manual Configuration
- In your project root, execute
composer require mltpss/php-sdk
. - Create a new SQweb object passing in its configuration through the constructor.
SQW_ID_SITE
andSQW_SITENAME
must be specified.
For additional settings, see "Options" below.
Manually
- Download the latest release of the SDK and unzip it in a folder named
sqweb
in your project root. -
Create a file named
sqweb.config
at the root of your project. This file should be one level up from the sqweb folder you just created, i.e. : -
In
sqweb.config
, paste the following configuration:Change
SQW_ID_SITE
with your website ID andSQW_SITENAME
with the name to show on the large Multipass button.
For additional settings, see "Options" below.
Usage
1. Initializing the SDK
First, you have to initialise SQweb variable on the pages where you wish to use it.
If you used composer:
If you installed manually:
2. Tagging your pages
Then, you need to add our JavaScript tag to your pages. This function will do it for you, and should be inserted before the closing </body>
tag in your HTML.
Make sure it is present on all your pages. Most likely you'll just have to add it to your template.
If you previously had a SQweb JavaScript tag, make sure to remove it to avoid any conflicts.
3.a Checking the credits of your subscribers
Check if the user has credits, so that you can disable ads and/or unlock premium content.
3.b Retrieving the user's email
If he wants it, the user can share his email with you, to retrieve it, check if the cookie named mltpss_e
exists. Inside will be a base64 encoded string you need to retrieve and decode on your side.
for instance:
This piece of code will store the email in the $email variable if the cookie is set.
4.a Showing the Multipass button
Use this code to display the Multipass button on your pages:
We have 3 additionals sizes for the button, to use it, pass a string to the function:
We also have another type of button, the free button, which offer to share the user's email with you. To display it, use this function:
4.b Customizing the Multipass button
If you want to customize our different type of button, put the following in your config file (.env
if you used composer and dotenv or sqweb.config
if you did not) of in the sqweb config file.
For instance:
SQW_LOGIN=Hello world
Will show Hello world
instead of Premium with Multipass
on the regular button for logged out visitors.
Button Model | Logged in | Logged out |
---|---|---|
Tiny | SQW_CONNECTED_TINY |
SQW_LOGIN_TINY |
Regular | SQW_CONNECTED |
SQW_LOGIN |
Large - before black dot | N / A | SQW_BTN_UNLIMITED |
Large - after black dot | N / A | SQW_BTN_NOADS |
Large connected | SQW_CONNECTED_S |
N / A |
5. More functions
Display a support div for your users
php $sqweb = new SQweb;
$sqweb->supportBlock();
We recommend that you use it with our other blocking function :
Display only a part of your content to non premium users
For instance:
Free users will see:
Display your content later for non paying users
Example:
Limit the number of articles free users can read per day
For instance, if I want to display only 5 articles to free users:
Options
Unless otherwise noted, these options default to false
. You can set them in your configuration.
Option | Description |
---|---|
SQW_DEBUG |
Output various messages to the browser console while the plugin executes. |
SQW_DWIDE |
Set to false to only enable SQweb on the current domain. Defaults to true . |
SQW_LANG |
We support these locales: en_US , en_GB and fr_FR . |
SQW_AUTOLOGIN |
Enable or disable our autologin feature. Defaults to true . |
Known Issues
If you change the value of SQW_DWIDE
after initial deployment, your users will have to log in again since their auth cookie will no longer be valid.
Troubleshooting
I am not seeing the Multipass button
Please make sure you have properly tagged your pages. Mind the position of the include and tag.
I can see the Multipass button, but I cannot login
The authentication requires cookies, which require fully qualified domain names. If you are testing on localhost or an IP, the authentication will succeed but won't be able to save a cookie in your browser.
Contributing
We welcome contributions and improvements.
Coding Style
All PHP code must conform to the PSR2 Standard.
Builds and Releases
See RELEASE.md.
Bugs and Security Vulnerabilities
If you encounter any bug or unexpected behavior, you can either report it on Github using the bug tracker, or via email at [email protected]
. We will be in touch as soon as possible.
If you discover a security vulnerability within SQweb or this plugin, please send an e-mail to [email protected]
. All security vulnerabilities will be promptly addressed.
License
Copyright (C) 2015-2017 – SQweb
This program is free software ; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation ; either version 3 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.