dario_swain / wall-poster-bundle
用于社交群体的墙面海报
dev-master
2014-08-09 20:36 UTC
Requires
- php: >=5.3.2
- ext-curl: *
- dg/twitter-php: 3.3
- facebook/php-sdk-v4: 4.0.*
- symfony/symfony: 2.*
This package is not auto-updated.
Last update: 2024-09-14 15:12:10 UTC
README
WallPosterBundle 组件允许您在社交群组、页面或时间轴上发布您的网站新闻。
安装
将此组件添加到您的 composer.json
文件
{
"require": {
"dario_swain/wall-poster-bundle": "dev-master"
}
}
您应该浏览 dario_swain/wall-poster-bundle
页面以选择要使用的稳定版本,避免使用 @stable
元数据约束。
在 app/AppKernel.php
中注册该组件
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new new WallPosterBundle\WallPosterBundle(),
);
}
在 routing.yml
中导入路由定义
# app/config/routing.yml
WallPosterBundle:
resource: "@WallPosterBundle/Resources/routing/routing.yml"
此路由 (/wall-poster/captcha) 用于输入验证码值,如果 vk.com
阻止您的 API 请求
在 app/config/config.yml
中启用组件配置
# app/config/config.yml
wall_poster:
vk:
access_token: VK_STANDALONE_APPLICATION_ACCESS_TOKEN
group_id: VK_GROUP_ID
facebook:
access_token: FACEBOOK_ACCESS_TOKEN
app_id: FACEBOOK_APPLICATION_ID
app_secret: FACEBOOK_APPLICATION_SECRET
page: FACEBOOK_PAGE_ID
twitter:
api_key: TWITTER_APP_KEY
api_secret: TWITTER_APP_SECRET
access_token: TWITTER_ACCESS_TOKEN
access_secret: TWITTER_ACCESS_TOKEN_SECRET
用法
您可以在社交网络上发布帖子,为此,您可以使用特殊的墙面海报服务。
帖子
为发布者创建 WallPosterBundle\Post\Post
<?php namespace Your\Namespace; use WallPosterBundle\Post\Post; class YourController extends Controller { public function updateAction() { /** Create you Post instance **/ $post = new Post(); /** Add image to post, you can provide absolute path for your local file and browser url to file **/ $post->createImage('/var/www/images/test.jpg','http://your_site.com/images/test.jpg') /** Add link to post **/ ->createLink('http://your_site.com/about') /** Add social tags **/ ->addTag('about') ->addTag('your_site') ->addTag('follow_me') /** Add message to your post **/ ->setMessage('Hello world!'); } }
创建帖子实例后,您可以使用社交网络提供者发布它。
社交网络提供者
该组件提供 wall_poster.vk
、wall_poster.facebook
和 wall_poster.twitter
服务,在创建帖子后
<?php namespace Your\Namespace; use WallPosterBundle\Post\Post; class YourController extends Controller { public function updateAction() { /** Create you Post instance **/ $post = new Post(); /** ... **/ $provider = $this->get('wall_poster.vk'); try { $post = $provider->publish($post); } catch(Exception $ex) { //Handle errors } } }