PHPackages                             giko/sinaweibo-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. giko/sinaweibo-bundle

ActiveSymfony-bundle

giko/sinaweibo-bundle
=====================

Giko Sina Weibo Bundle

1.0.0(14y ago)4702MITPHPPHP &gt;=5.3.2

Since Dec 13Pushed 12y ago2 watchersCompare

[ Source](https://github.com/gikoluo/SinaweiboBundle)[ Packagist](https://packagist.org/packages/giko/sinaweibo-bundle)[ Docs](http://friendsofsymfony.github.com)[ RSS](/packages/giko-sinaweibo-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

介绍
==

[](#介绍)

本组件可将新浪微博集成到Symfony2中。 组件提供新浪微博登陆认证，并可利用新浪微博接口进行微博发布等分享行为。 本组件整合FOSUserBundle，保存新浪微博登陆后的用户信息

`组件仅支持Symfony2.1+`

安装
--

[](#安装)

============

### Step 1. 将本组件 `giko/sinaweibo-bundle` 和 `friendsofsymfony/user-bundle` 添加到 `composer.json` 文件:

[](#step-1-将本组件-gikosinaweibo-bundle-和-friendsofsymfonyuser-bundle--添加到-composerjson-文件)

```
        "require": {
            #...
            "friendsofsymfony/user-bundle": "dev-master",
            "giko/sinaweibo-bundle": "dev-master",
        }

```

### Step 2. 使用Git submodules的方式将 ElmerZhang / WeiboSDK 新浪微博代码添加代码库。 或者你也可以通过手动下载的方式下载并解压到对应的目录。

[](#step-2-使用git-submodules的方式将-elmerzhang--weibosdk-新浪微博代码添加代码库-或者你也可以通过手动下载的方式下载并解压到对应的目录)

此步骤现在省略吧。 `giko/sinaweibo-bundle` 中已经自带了一个WeiboSDK copy，而且修改了几行代码来解决一个notiec错误。。

```
          $ git submodule add git://github.com/ElmerZhang/WeiboSDK.git vendor/sinalib

```

### Step 3. 在应用内核代码中注册组件：

[](#step-3-在应用内核代码中注册组件)

```
          //app/AppKernel.php
          public function registerBundles()
          {
              return array(
                  // ...
                  new FOS\UserBundle\FOSUserBundle(),
                  new Giko\SinaweiboBundle\GikoSinaweiboBundle(),
                  // ...
              );
          }
```

### Step 4. 配置FOS User。

[](#step-4-配置fos-user)

> Note: 关于FOS User的更多信息，请参考

```
	#app/config/config.yml
	#FOS User
	fos_user:
	    db_driver:      orm # can be orm or odm
	    firewall_name:  main
	    user_class:     Acme\UserBundle\Entity\User
	    use_listener:           true
	    use_username_form_type: true
	    service:
	        mailer:                 fos_user.mailer.default
	        email_canonicalizer:    fos_user.util.canonicalizer.default
	        username_canonicalizer: fos_user.util.canonicalizer.default
	        token_generator:        fos_user.util.token_generator.default
	        user_manager:           fos_user.user_manager.default
	    group:
	        group_class: Acme\UserBundle\Entity\Group
	    profile:
	        form:
	            type:               fos_user_profile
	            name:               fos_user_profile_form
	            validation_groups:  [Profile, Default]

```

### Step 5. 配置`新浪微博`组件:

[](#step-5-配置新浪微博组件)

```
	#app/config/config.yml
	giko_sinaweibo:
	    file: %kernel.root_dir%/../vendor/sinalib/saetv2.ex.class.php
	    consumer_key: xxxxxx
	    consumer_secret: xxxxxx
	    callback_url: http://localhost:8000/login_check
```

### Step 6. 使用FOSUserBundle建立你自己的用户模块

[](#step-6-使用fosuserbundle建立你自己的用户模块)

建立用户Model，并增加几个新浪微博字段：

```
