Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using thujohn/twitter with philo/twitter #35

Closed
nrs365 opened this issue Jul 26, 2014 · 10 comments
Closed

Using thujohn/twitter with philo/twitter #35

nrs365 opened this issue Jul 26, 2014 · 10 comments

Comments

@nrs365
Copy link

nrs365 commented Jul 26, 2014

I'm writing a Laravel 4 app that uses the getUserTime function of Thujohn (and works wonderfully) but for another aspect of my app, I'm using philo/twitter's oauth (which also works very well). The problem is that the namespaces for both of the packages are the same. Do you have any suggestions on how to get the Thujohn package to be recognized specifically for the functions I need it for and have function calls get confused with the philo/twitter package? I tried renaming the alias, hardcoding the use in the controllers, etc. If it could be a clue to help you help me, I have noticed that when I reverse the order of the package listing in config/app.php that the opposite package will start working.
Any advice would be much appreciated! Thanks!!

@thujohn
Copy link
Collaborator

thujohn commented Jul 29, 2014

Hi.

Did you try renaming the two aliases ? e.g. Jtwitter and Ptwitter

@nrs365
Copy link
Author

nrs365 commented Jul 30, 2014

I tried renaming the aliases, and stackoverflow/stacktrace and logs. Can't get the two working even after changing the aliases because the namespaces are the same. Ideas?

@thujohn
Copy link
Collaborator

thujohn commented Jul 30, 2014

I think I fixed it.

Can you try again with the two aliases ?

@nrs365
Copy link
Author

nrs365 commented Aug 11, 2014

I did a composer update and the two packages still have a namespace conflict. Here is an example of how I'm trying to use the two packages together:

public function showHome()
{
$tweets = ThujohnTwitter::getUserTimeline(array('screen_name' => '210axs', 'count' => 1, 'format' => 'array'));
$name = ($tweets[0]['user']['name']);
$statuses_count = ($tweets[0]['user']['statuses_count']);
$profile_image = ($tweets[0]['user']['profile_image_url_https']);
dd($tweets);
$data = [
'user' => $user,
'name' => $name,
'statuses_count' => $statuses_count,
'profile_image' => $profile_image
];
dd($data);
//return View::make('index')->with($data);
}

public function oauth() {
    // Reqest tokens
    $tokens = PhiloTwitter::oAuthRequestToken();

    // Redirect to twitter
    PhiloTwitter::oAuthAuthenticate(array_get($tokens, 'oauth_token'));
    exit;
}

public function callback() {
    //Oauth token
    $token = Input::get('oauth_token');

    // Verifier token
    $verifier = Input::get('oauth_verifier');

    // Request access token
    $accessToken = PhiloTwitter::oAuthAccessToken($token, $verifier);
    dd($accessToken);
    $twitterId = $accessToken['user_id'];
    $twitterUsername = $accessToken['screen_name'];
    $twitterToken = $accessToken['oauth_token'];
    $twitterTokenSecret = $accessToken['oauth_token_secret'];

} 

@thujohn
Copy link
Collaborator

thujohn commented Aug 11, 2014

I have the same and it works

@nrs365
Copy link
Author

nrs365 commented Aug 11, 2014

I'm testing it with both packages and my alias are written like this:

'PhiloTwitter' => 'Philo\Twitter\Facades\Twitter',
'ThujohnTwitter' => 'Thujohn\Twitter\TwitterFacade',

And when I try to use the PhiloTwitter package it says it's looking for the PhiloTwitter Oauth method in ThujohnTwitter "Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Call to undefined method Thujohn\Twitter\Twitter::oAuthRequestToken()"

@thujohn
Copy link
Collaborator

thujohn commented Aug 11, 2014

I created a new project with only this and it works : http://laravel.io/bin/kkBBm

Maybe you should try in a new project too.

@nrs365
Copy link
Author

nrs365 commented Aug 11, 2014

ok let me keep trying :)

@nrs365
Copy link
Author

nrs365 commented Aug 28, 2014

I started using the updated version of the package with the new oauth functions. It's working really well :) It solves the problem I was having because now I only have to use one package for everything. Thanks!

@j3j5
Copy link
Contributor

j3j5 commented Aug 29, 2014

I'm glad somebody else found it useful. This is a great package but I really was missing the functions needed to handle login with Twitter. Let me know if you find any issue, I'll be happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants