thujohn/share

使用 Laravel 4 分享链接

dev-master 2014-05-20 17:31 UTC

This package is auto-updated.

Last update: 2024-08-24 04:37:35 UTC


README

使用 Laravel 4 分享链接

Build Status

安装

thujohn/share 添加到 composer.json

"thujohn/share": "dev-master"

运行 composer update 以拉取 Share 的最新版本。

现在打开 app/config/app.php 并将服务提供者添加到您的 providers 数组中。

'providers' => array(
    'Thujohn\Share\ShareServiceProvider',
)

现在添加别名。

'aliases' => array(
    'Share' => 'Thujohn\Share\ShareFacade',
)

使用方法

获取一个链接(以 Twitter 为例)

Route::get('/', function()
{
	return Share::load('http://www.example.com', 'My example')->twitter();
});

返回一个字符串

https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Link+description

获取多个链接

Route::get('/', function()
{
	return Share::load('http://www.example.com', 'Link description')->services('facebook', 'gplus', 'twitter');
});

返回一个数组

{"facebook":"https:\/\/www.facebook.com\/sharer\/sharer.php?u=http%3A%2F%2Fwww.example.com&title=Link+description","gplus":"https:\/\/plus.google.com\/share?url=http%3A%2F%2Fwww.example.com","twitter":"https:\/\/twitter.com\/intent\/tweet?url=http%3A%2F%2Fwww.example.com&text=Link+description"}

可用服务

  • Delicious : delicious
  • Digg : digg
  • Evernote : evernote
  • Facebook : facebook
  • Gmail : gmail
  • Google Plus : gplus
  • LinkedIn : linkedin
  • Pinterest : pinterest
  • Reddit : reddit
  • Scoop.it : scoopit
  • Springpad : springpad
  • Tumblr : tumblr
  • Twitter : twitter
  • Viadeo : viadeo
  • vk.com : vk