IFrame
Embed LikeCoin button using <iframe>

Instructions

1. Construct an embedded URL according to the following format:

1
https://button.like.co/in/embed/{{LikerID}}/button?referrer={{referrer}}&type={{type}}
Copied!
Parameter
Type
Required?
Description
LikerID
string
required
The author of the content
referrer
string
required
The source (canonical) URL of the content in encodeURIComponent() format (this also works as the content key)
type
string
optional
wp for WordPress site, omit for the others
preview
number
optional
Set to 1 to set the button to preview mode. This stop the button from automatically calling like.co API. Useful for develop/staging environment e.g. to prevent leaking dev server's address.
For testing purpose, you may use button.rinkeby.like.co instead of button.like.co
In case of iframe sandbox, allow-scripts, allow-same-origin, allow-popups allow-popups-to-escape-sandbox, allow-top-navigation-by-user-activation, allow-storage-access-by-user-activation are needed for proper register/login functionality.
2 Embed the sample HTML and replace {{ src }} with the embed URL into your HTML
3 Include the CSS code
4 (Optional) Update referrer via postMessage
The LikeCoin button <iframe>'s src (especially the referrer param) should be updated to when the URL is changed. In case updating <iframe>'s src is not possible (e.g. for some SPA usecases), you may call postMessage() to the <iframe> with following payload to update the referrer.
1
{
2
action: 'SET_REFERRER',
3
content: { referrer: `${ newReferrer||window.location.href }` }
4
}, 'https://button.like.co'
Copied!

Reference Repository

Integration Examples

Last modified 1yr ago