sqweb/laravel_sdk

该软件包已被废弃,不再维护。作者建议使用 mltpss/laravel-sdk 软件包。

Laravel用户的Multipass软件包

v1.3.4 2018-04-16 14:14 UTC

README

Build Status Latest Stable Version Dependency Status

此软件包允许您轻松地将SQweb集成到由Laravel驱动的网站中。

要求

此SDK已在PHP 5.5及更高版本上进行了测试。

我们无法为早期版本提供官方支持。有关PHP分支生命周期的更多信息,请参阅此页面

安装

此软件包适用于由Laravel驱动和高级集成的网站。

如果您使用WordPress,我们已为您简化操作。直接从WordPress.org下载SQweb插件 ,或在此查看源代码

使用Composer

  1. 在项目根目录中,执行 composer require mltpss/laravel-sdk;

  2. 现在,转到config/app.php并添加以下行到您的providers数组

    Sqweb\Laravel_sdk\SqwebServiceProvider::class,
  3. 在项目根目录中输入 php artisan vendor:publish 以创建配置文件。

  4. .env中,粘贴以下配置,并将变量SQW_ID_SITE设置为您的网站ID,将变量SQW_SITENAME设置为要在大Multipass按钮上显示的名称。

    SQW_ID_SITE=YOUR_WEBSITE_ID
    SQW_SITENAME=YOUR_WEBSITE_NAME

有关其他设置,请参阅下面的“选项”。

使用方法

SDK非常简单易用。以下是使用方法:

1. 标记您的页面

此函数输出SQweb JavaScript标签。将其插入到您的HTML中的</body>标签之前。

{{ $sqweb->script() }}

如果您之前已经有了SQweb JavaScript标签,请确保将其删除以避免冲突。

2. 检查您的订阅者的积分

此函数检查用户是否有积分,这样您就可以禁用广告并/或解锁付费内容。

使用方法如下

@if ($sqweb->checkCredits())
    // CONTENT
@else
    // ADS
@endif

3. a) 显示Multipass按钮

最后,使用此代码将Multipass按钮添加到您的页面

{{ $sqweb->button() }}

我们提供了不同大小的按钮,要使用它们,请将字符串传递给函数,例如

{{ $sqweb->button('tiny') }}
{{ $sqweb->button('slim') }}
{{ $sqweb->button('large') }}

Example Buttons

3. b) 自定义Multipass按钮

如果您想自定义我们的不同类型的按钮,请将以下内容放在您的.env文件或sqweb配置文件中。例如: SQW_LOGIN=Hello world 将在未登录访客的常规按钮上显示 Hello world 而不是 带有Multipass的付费

按钮模型 已登录 未登录
小型 SQW_CONNECTED_TINY SQW_LOGIN_TINY
常规 SQW_CONNECTED SQW_LOGIN
大型 - 在黑点之前 N / A SQW_BTN_UNLIMITED
大号 - 在黑点之后 N / A SQW_BTN_NOADS
大号连接 SQW_CONNECTED_S N / A

4. 更多功能

为您的用户显示“支持我们”的消息

/**
 * Display a support block.
 */

function supportBlock() {   }
``

For instance:

```php
{!! $sqweb->supportBlock !!}

将显示该块。

为您的用户显示锁定div

/**
 * Display a locking block.
 */

function lockingBlock() {   }
``

For instance:

```php
{!! $sqweb->lockingBlock !!}

我们建议您将其与我们的过滤功能结合使用,例如

@if($sqweb->waitToDisplay('2016-09-15', 2))
    // The content here will appear the 2016-09-17, 2 days after the publication date for non paying users.
@else
    // Here you can put content that free users will see before the content above is available for all.
    // {!! $sqweb->lockingBlock !!}
@end

仅向非高级用户显示您内容的一部分

/**
 * Put opacity to your text
 * Returns the text with opcaity style.
 * @param text, which is your text.
 * @param int percent which is the percent of your text you want to show.
 * @return string
 */
    public function transparent($text, $percent = 100) { ... }

示例

{!! $sqweb->transparent('one two three four', 50) !!}

将显示免费用户

one two

稍后向非付费用户显示您的内容

    /**
     * Display your premium content at a later date to non-paying users.
     * @param  string  $date  When to publish the content on your site. It must be an ISO format(YYYY-MM-DD).
     * @param  integer $wait  Days to wait before showing this content to free users.
     * @return bool
     */
    public function waitToDisplay($date, $wait = 0) { ... }

示例

@if($sqweb->waitToDisplay('2016-09-15', 2))
    // The content here will appear the 2016-09-17, 2 days after the publication date for non paying users.
@else
    // Here you can put content that free users will see before the content above is available for all.
@end

限制免费用户每天可阅读的文章数量

    /**
     * Limit the number of articles free users can read per day.
     * @param $limitation int The number of articles a free user can see.
     * @return bool
     */
    public function limitArticle($limitation = 0) { ... }

示例:如果我想仅向免费用户显示5篇文章

@if ($sqweb->limitArticle(5) == true)
    echo "This is my article";
@else
    echo "Sorry, you reached the limit of pages you can see today, come back tomorrow or subscribe to Multipass to get unlimited articles !";
@endif

选项

除非另有说明,否则这些选项默认为false。您可以在您的.env文件中设置它们。

选项 描述
SQW_DEBUG 在插件执行时向浏览器控制台输出各种消息。
SQW_DWIDE 设置为false以仅启用当前域上的SQweb。默认为true
SQW_LANG 我们支持以下区域设置:en_USen_GBfr_FR
SQW_AUTOLOGIN 启用或禁用我们的自动登录功能。默认为true

贡献

我们欢迎贡献和改进。

编码风格

所有PHP代码必须符合PSR2标准

构建和发布

请参阅RELEASE.md

错误和安全漏洞

如果您遇到任何错误或意外行为,您可以通过GitHub使用错误跟踪器报告,或者通过电子邮件至hello@sqweb.com。我们将尽快与您联系。

如果您在SQweb或此插件中发现安全漏洞,请通过电子邮件至security@sqweb.com。漏洞将得到及时处理。

许可

版权(C)2018 – SQweb

此程序是免费软件;您可以在自由软件基金会的GNU通用公共许可证的条款和条件下重新分配和/或修改它;许可证版本3或任何后续版本。

此程序是免费提供给用户使用的,但没有任何担保;甚至没有关于其适销性或适用于特定目的的暗示性担保。有关详细信息,请参阅GNU通用公共许可证

您应该已经收到了随本程序一同附带的GNU通用公共许可证的副本。如果没有收到,请参阅https://gnu.ac.cn/licenses/