Up until now we have only been able to offer the Glimta Unlock service with links beginning with https://glimta.com/u/…
Now, we have added support for native links!
With this, the link can be something like:
https://www.thenewspaper.com/some-locked-news-article#GLIMTA_UNLOCK:ABC123
(for client side paywalls)
…or
https://www.thenewspaper.com/some-locked-news-article?GLIMTA_UNLOCK:ABC123
(for server side paywalls)
Client side or Server side paywalls?
Paywalls can be of two types: Client or Server side.
With client side paywalls, the page content is protected with code embedded inside the web page, in the html code. (=The article is there but only readable for subscribers).
Server side paywalls checks if the user is logged in as a valid subscriber before sending out the article.
Glimta supports both Client and Server side paywalls.
Client side Paywalls
For newspapers using a client-side (frontend) paywall technology, the unlock token will be added to the page’s url with an #.
Example:
https://www.thenewspaper.com/some-locked-news-article#GLIMTA_UNLOCK:ABC123
Add the script code below to your sites html and complete with the code needed to remove the paywall from the page
<script src="https://glimta.com/scripts/unlock.js"></script>
<script>
$glimta.unlock(function() {
// TODO:
// ADD YOUR CODE TO REMOVE THE PAYWALL FOR THE ARTICLE/PAGE HERE
});
</script>
Server side Paywalls
For newspapers using a server side (backend) paywall technology, the unlock token will be added to the page’s url with a ?.
Example:
www.thenewspaper.com/some-locked-news-article?GLIMTA_UNLOCK=ABC123
You need to add code to your servers backend that looks for this parameter, and if found, executes a query towards GLIMTAs REST-endpoint “https://glimta.com/u/<token>” to check if the unlock is still valid or not.
The response to this call is:
The response to this call is:
# VALID
{
"status": true,
"visit_id": "ABC123"
}
# EXPIRED
{
"status": false,
"expired": true,
"expired_date": "yyyy-mm-dd" // can be null
"expired_total": 0..nn // can be null
}
A simple (and naive) implementation in Python might look something like below:
import requests
...
# Your Server's GET requests endpoint
def get(request):
# get climta unlock token from querystring
glimta_token = request.args.get("GLIMTA_UNLOCK")
if glimta_token:
# call GLIMTA REST-api to check if unlock is valid
r = requests.get("https://glimta.com/u/" + glimta_token)
if r.status_code == 200:
glimta_unlock = r.json()
if glimta_unlock["status"] == True:
# 1 ADD CODE TO REMOVE THE PAYWALL
# 2 INCLUDE THE SCRIPT "https://glimta.com/scripts.js" ON THE PAGE
# 3 INJECT A JAVASCRIPT TO CALL "_rp(visit_id)" WHERE visit_id IS FOUND IN THE RESPONSE: r["visit_id"]
#
# FOR EXAMPLE IN TEMPLATE:
#
# <script>_rp('{visit_id}');</script>
# optional: present some info to user that the unlock is not valid
else:
pass
/Mikael Runhem
