laravel 分享功能

laravel 分享功能

扩展包:

chencha/share

http://packagist.p2hp.com/packages/chencha/share

简介:

常见的分享是一个固定写死的链接,点击后跳转对应网站的分享页面,laravel 有专门的分享扩展包 chencha/share,能更加便捷的生成分享链接,主要针对国外的网站如:facebook、twitter、pinterest等

安装:

composer require chencha/share

config/app.php

'providers' ==> Chencha\Share\ShareServiceProvider::class,
'aliases' ==> 'Share' => Chencha\Share\ShareFacade::class,

使用:

$share = Share::load('要分享页面的url', '链接描述')->services('facebook','twitter','pinterest');

//$share 打印结果
array:3 [▼
  "facebook" => "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Floc.nva.com%2Fteam&title=NVA"
  "twitter" => "https://twitter.com/intent/tweet?url=http%3A%2F%2Floc.nva.com%2Fteam&text=NVA"
  "pinterest" => "http://pinterest.com/pin/create/button/?url=http%3A%2F%2Floc.nva.com%2Fteam&description=NVA"
]
posted @ 2019-12-05 16:30  pine007  阅读(455)  评论(0编辑  收藏  举报