Download the PHP package questpass/questpass-php-sdk without Composer

On this page you can find all versions of the php package questpass/questpass-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package questpass-php-sdk

Questpass PHP SDK

Easy custom integration with only few steps required to start displaying ads.

Travis-ci

Install

composer require questpass/questpass-php-sdk

Quick start

Create Content with your defaults to start serving ads.

It is a façade which provides all of the functionalities for displaying ads and maintaining its placement.

Constructor arguments are:

apiUrl Questpass services endpoint

serviceId Can be either a Service UUID or callable which is used when fetching javascript file contents from API. You can find yours by navigating to details of a service from Dashboard.

storage Instance of Storage implementation which holds javascript file contents to prevent performing API requests everytime we need to display it. We provide two implementations: WordpressStorage and InMemoryStorage

httpClient Implementation of HTTP client which is used to fetch JavaScript

positioningSettings Instance of an PositioningSettings that returns values that are used to position a quest during rendering the content. There are two pre-defined strategies: PositioningSettings::STRATEGY_UPPER and PositioningSettings::STRATEGY_LOWER. Use factory method as a best practice.

contextProviders (optional) An array of context providers which are used to get template values used in rendering javascript file. There are ready to use implementations which are functionaly divided, i.e. ElementsContextProvider.

Now, we can fetch javascript file that will eventually render ads.

We can pass an array of context providers just like for constructor. They are responsible for replacing placeholders inside javascript file fetched from API with integration specific values.

Example above will return javascript source code what will use random IDs as containers for ads. It's then possible to fetch generated IDs by using methods:

Automatic Ad placement

We provide method to help you place ad in best spot inside HTML content. To make use of it call prepare method with arguments:

NOTE: adContainerHtml and reminderAdContainerHtml must be the same as those used when fetching javascript file.

Manual Ad placement

You can also use function below to find <div class="questo-should-be-inserted-here"></div> and replace with the ad:

If you just want to check if there is a div in the content use:

The function will return true if <div class="questo-here"></div> exists in the content.

Prepared content

Both autoPrepare and manualPrepare return PreparedContent instances which in addition to hold the content also has a flag which tells wether it is valid to display a questo - isAdReady method.

To apply JavaScript plugin source:

Overview

Javascript Storages

We use Storage interface to communicate intentions related to javascript contents persistance not to perform multiple API calls and thus provide better user experience.

WordpressStorage

Uses Wordpress get_option function to persist Javascript file contents and caches it for 24 hours.

InMemoryStorage

Basic implementation which holds Javascript file contents in memory. Most likely used for poc use only.

Context Providers

To properly render javascript that displays ads we use template that should be populated with values that set few important variables. There are two ready to use implementations that provide them with nice interface.

ElementsContextProvider

Most important context provider which tells names of HTML containers that are used for rendering ads. Constructor parameters are optional:

By default both mainQuestId and reminderQuestId are generated with random string.

NOTE: For all testing purposes, including preview mode in CMS of any kind, isDraft should be set to true.

SubscriptionsContextProvider

This provides variables that are crucial to enable Subscription feature alowing to identify readers authenticated via OAuth2.

Subscriber support (via Questpass OAuth2)

We provide OAuth2 client that utilizes Questpass backend to authorize users as subscribers. The steps are:

NOTE: It's important to run $subscriber->isSubscriptionValid() before anything that is related to ad-free experience.

Webhooks

We will send POST request to you Service webhook URL with form-data with one of the following actions. Each action represent changes that need to be undertaken on your end for coherent experience.

You should respond with JSON {"status": "OK"}. If not, we will retry using exponential back-off strategy for 10 times.

Service status update

Action: questo_update_service_status_option

Once received you should ask API back for current status. Example:

In response there is an array with following keys:

Use this one to turn on and off any ad displaying related activity.

This one should be used when fetching Javascript plugin, as it tells whether to turn Subscriptions feature on or off.

Subscription status update

Action: questo_update_subscription_option

This one is fired when Subscription feature is toggled either on or off. Now to fetch the actual value please use same method as described for Service status update.

Forced Javascript update

Action: questo_force_update_javascript

From time to time we might call your endpoint to tell that there is new Javascript file available so that you can update it in your Storage.

Image

Example below shows details of how javascript could be replaced with new one:

JavaScript Events

Click here to read about JavaScript events.

Examples


All versions of questpass-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^5.3.2 || ^7.0
kub-at/php-simple-html-dom-parser Version ^1.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package questpass/questpass-php-sdk contains the following files

Loading the files please wait ....