承接 lulco/rich-social-messages 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lulco/rich-social-messages

Composer 安装命令:

composer require lulco/rich-social-messages

包简介

Library for parsing and improving mesages from social networks

README 文档

README

Library for parsing and improving mesages from social networks.

Installation

Composer

The fastest way to install Rich social messages is to add it to your project using Composer (http://getcomposer.org/).

  1. Install Composer:
    curl -sS https://getcomposer.org/installer | php
    
  2. Require Rich social messages as a dependency using Composer:
    php composer.phar require lulco/rich-social-messages
    
  3. Install Rich social messages:
    php composer.phar update
    

Usage

If you have some Twitter tweets, Facebook statuses or Instagram posts as plaintext, you can get more information about them using this library.

Twitter

$message = new \RichSocialMessages\Message\Tweet("My tweet with #tag1 and #tag2 and @user1 and @user2 and http://example.com");
$message->getTags();    // will return ['tag1', 'tag2']
$message->getUsers();    // will return ['user1', 'user2']
$message->getLinks();    // will return ['http://example.com']

Instagram

$message = new \RichSocialMessages\Message\InstagramPost("My instagram post with #tag1 and #tag2 and @user1 and @user2 and http://example.com");
$message->getTags();    // will return ['tag1', 'tag2']
$message->getUsers();    // will return ['user1', 'user2']
$message->getLinks();    // will return ['http://example.com']

Facebook

$message = new \RichSocialMessages\Message\FacebookStatus("My facebook status with Name #tag1 and #tag2 and http://example.com");
$message->getTags();    // will return ['tag1', 'tag2']
$message->getUsers();    // will return []
$message->getLinks();    // will return ['http://example.com']

Unfortunatelly, Facebook statuses don't contain users with some identifiers as Twitter and Instagram does (@user) so it is not possible to parse users automatically. But if you somehow know which parts of Facebook status mention Facebook users, you can identify them in second parameter of FacebookStatus constructor:

$message = new \RichSocialMessages\Message\FacebookStatus("My facebook status with Name #tag1 and #tag2 and http://example.com", [4 => 'my_username']);    // 4 is index of word which contains user (Name) and my_username is user's username on Faceboook
$message->getTags();    // will return ['tag1', 'tag2']
$message->getUsers();    // will return [4 => 'name_surname']
$message->getLinks();    // will return ['http://example.com']

Transformation

Second part of this library allows you to create richer message from plaintext message, for example from tweet My tweet with #tag1 and #tag2 and @user1 and @user2 and http://example.com, you can get this: My tweet with <a href="https://twitter.com/hashtag/tag1" target="_blank">#tag1</a> and <a href="https://twitter.com/hashtag/tag2" target="_blank">#tag2</a> and <a href="http://twitter.com/user1" target="_top">@user1</a> and <a href="http://twitter.com/user2" target="_top">@user2</a> and <a href="http://example.com" target="_blank">http://example.com</a>

How to do it?

First you have to setup your Transformer:

$transformer = new \RichSocialMessages\Transformer\TwitterTransformer();
$transformer->setUserLinkTarget('_top');
$transformer->setTagLinkTarget('_blank');
$transformer->setLinkLinkTarget('_blank');

And then you can pass the message to the transformer:

$transformer->transform(new \RichSocialMessages\Message\Tweet("My tweet with #tag1 and #tag2 and @user1 and @user2 and http://example.com"));

The same way you can use for transforming Facebook statuses and Instagram posts. You just need to setup FacebookTransformer and InstagramTransformer instead of TwitterTransformer.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固