faceleg/php-socializer

为您的项目提供简单易用且可定制的社交集成

v0.0.2 2012-10-15 04:37 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:13:17 UTC


README

PHP模块,旨在让添加社交分享按钮变得更加愉快。包括Google Analytics钩子,以启用分享活动的跟踪。

目前支持Twitter、Facebook、Google Plus、LinkedIn、StumbleUpon、GitHub和Flattr按钮。

基本示例

PHP Socializer Basic Example

以下代码可以创建这些按钮

<?php
use COI\Social;

include_once 'include.php'; // Contains constants
include_once 'require.php'; // Not necessary if you're using an autoloader

/* Somehere in your config */
 
// Create a manager for the Twitter, Google+ & LinkedIn button set
new Social\Manager(array(
    'twitter' => new Social\Twitter(array(
        'username' => 'pagesofinterest',
    )),
    'googleplus' => new Social\GooglePlus(array(
        'size' => 'medium'
    )),
    'linkedIn' => new Social\LinkedIn()
), array(
    'fadeIn' => 400
));
 
/* Where the buttons should be displayed */
echo $socialManager->render(array(
    // These options override those used in the manager initialisation above
    'url' => 'http://pagesofinterest.net/',
    'title' => 'Pages of Interest', 
));
 
/* In your footer, just above the closing <body> tag */
// Output the <script> with src pointing to the combined, compressed & cached JavaScript
echo COI\Social\Manager::combinedJavaScript();
?>

单个按钮

PHP Socializer Single Button

要渲染单个按钮,使用以下语法

<?php
use COI\Social;

include_once 'include.php'; // Contains constants
include_once 'require.php'; // Not necessary if you're using an autoloader

// Render a single button
echo Social\GitHub(array(
    'user' => 'faceleg',
    'repository' => 'COI-Social',
    'type' => Social\GitHub\Type\WATCH
));
?>

鸣谢

GitHub按钮由Mark Dotto创建 - GitHub按钮