viChaunter / socialshare
社交分享按钮,简单易用
dev-master
2018-07-10 11:01 UTC
Requires
- php: >=5.6
This package is not auto-updated.
Last update: 2024-09-19 17:51:38 UTC
README
SocialShare 允许开发者轻松地在他们的应用程序中构建社交分享按钮。
SocialShare 的主要目标是尽可能简单地将所有社交网络(和工具)的分享按钮添加到任何网站中,而不依赖于其他包。
用法
SocialShare 将简要提供使用示例。
使用它的简单方法是使用所需的参数调用 Buttons 类,或直接调用每个按钮
//remember to use class namespace $shareButtons = new Buttons(); //this will create all disponible buttons $shareButtons->setUrl($currentUrl); //pass your current url from your script foreach($shareButtons as $button){ echo $button->getHtml(); } //result will be links to each social network with href and this format //<a class="btn btn-social-icon btn-facebook" href="https://#/sharer/sharer.php?u=http%3A%2F%2Fyour.domain" target="_blank">Facebook</a>
调用 Buttons 时,您可以传递两个属性,一个是限制您想要看到的社交网络,另一个是 iconPack(如果已定义)。目前仅支持 fontAwesome。
$shareButtons = new Buttons(['facebook','twitter'], 'fontAwesome'); $shareButtons->setUrl($currentUrl); //pass your current url from your script foreach($shareButtons as $button){ echo $button->getHtml(); } //this will result //<a class="btn btn-social-icon btn-facebook" href="https://#/sharer/sharer.php?u=http%3A%2F%2Fyour.domain" target="_blank"><i class="fa fa-facebook"></i></a>
####使用 Nette 框架的示例用法。
在任何表示者中,只需添加以下行
$shareButtons = new Buttons(null, 'fontAwesome'); $shareButtons->setUrl($this->getHttpRequest()->getUrl()->absoluteUrl); $this->template->shareButtons = $shareButtons->getAll();
然后在 latte 中可以使用循环
{ifset $shareButtons} {foreach $shareButtons as $shareButton} {$shareButton->getHtml()|noescape} {/foreach} {/ifset}
需求
- PHP 5.x+
安装
要安装 SocialShare,您现在可以克隆项目在您的项目中的存储库 Github。
版本状态
问题、帮助和支持?
对于一般问题(例如,“如何”问题),请在 Github 的问题跟踪器中留言。
许可证
SocialShare PHP 库是根据 MIT 许可证条款发布的。
有关完整的版权声明和免责声明,请参阅 LICENSE。