2014-10-17 55 views
0

我用HWIOauthBundle和FOSUerBunlde用於連接到Twitter,嘗試改變CLIENT_ID和client_secret動態,和我的想法不覆蓋服務:hwi_oauth.abstract_resource_owner.oauth1,但沒有執行覆蓋:hwioauth動態CLIENT_ID Symfony2的

我service.yml:

parameters: 
    my_user_provider.class: Wf\DeckBundle\Security\Core\User\FOSUBUserProvider 

services: 
    my_user_provider: 
     class: "%my_user_provider.class%" 
     #this is the place where the properties are passed to the UserProvider - see config.yml 
     arguments: [@fos_user.user_manager,{twitter: twitterID }] 
     arguments: [@doctrine.orm.entity_manager] 
    security_handler: #este no es necesario 
     class: Company\Bundle\Handler\SecurityHandler 
     arguments: [@router] 
    test_service: 
     class: Wf\DeckBundle\Services\TestService 
     arguments: ['@service_container'] 
    deck_user_manager: 
     class: Wf\DeckBundle\Services\DeckUserManager 
     arguments: [@security.encoder_factory, @fos_user.util.username_canonicalizer, @fos_user.util.email_canonicalizer, @fos_user.entity_manager, Wf\DeckBundle\Entity\User] 
    twitter_api: 
     class: Wf\DeckBundle\Services\TwitterService 
     arguments: [consumerKey,consumerSecret] 
    deck.user.roles: 
     class: Wf\DeckBundle\Services\RolesDeckService 
     arguments: ['%security.role_hierarchy.roles%'] 
    hwi_oauth.abstract_resource_owner.oauth1: 
     class: Wf\DeckBundle\OAuth\ResourceOwner\GenericOAuth1ResourceOwner 
     abstract: true 
     parent: hwi_oauth.abstract_resource_owner.generic 
     arguments: ['@hwi_oauth.storage.session'] 

我的課:

<?php 
namespace Wf\DeckBundle\OAuth\ResourceOwner; 

use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth1ResourceOwner as Based; 

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 

/** 
* Description of GenericOAuth1ResourceOwner 
* 
* @author francisco 
*/ 
class GenericOAuth1ResourceOwner extends Based{ 

    public function getRequestToken($redirectUri, array $extraParameters = array()) 
    { 
     $timestamp = time(); 
     \Kint::dump($timestamp); // to show pass overwrite 
     exit; 

    } 

    /** 
    * {@inheritDoc} 
    */ 


} 

,但沒有工作,誰可以指導我,謝謝

回答

1

我使用Compiler Pass和自定義資源所有者解決了同樣的問題(在我的情況下,我需要使它適用於Facebook而不是Twitter,但我認爲同樣適用)。我的博客上的詳細信息: http://www.mathril.com/en/blog/8/how-to-load-facebook-client_id-and-client_secret-values-from-database-for-hwioauthbundle

+0

請回答這裏的問題,而不是隻是鏈接到另一個網站。其他網址會變得過時,但如果您在此處撰寫簡潔的答案,它將會很有幫助。 – 2015-07-12 01:38:03

+0

感謝這個鏈接是完美的。 – ncw2233 2015-12-10 18:48:02

+0

該鏈接已損壞 – muhsin 2018-02-20 20:33:44