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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined ttwiter index #72

Closed
kriskornel opened this issue Mar 25, 2015 · 12 comments
Closed

Undefined ttwiter index #72

kriskornel opened this issue Mar 25, 2015 · 12 comments

Comments

@kriskornel
Copy link

Hi, Mr. John. I got error when trying to initiate your package. It showed error like this:

ThanksForYourHelp 馃憤

ErrorException (E_UNKNOWN)

Undefined index: ttwitter::config
Open: /var/www/html/integration/vendor/thujohn/twitter/src/Thujohn/Twitter/Twitter.php

* Only for debugging
*/
private $debug;
private $log = [];
public function __construct($config = [], SessionStore $session)
{
if (is_array($config['ttwitter::config']))
{
$this->tconfig = $config['ttwitter::config'];
@kriskornel kriskornel changed the title Undefi Undefined ttwiter index Mar 25, 2015
@thujohn
Copy link
Collaborator

thujohn commented Mar 25, 2015

Which version of Laravel are you using ?
Have you added the provider and alias ?
Did you publish the config ?

@kriskornel
Copy link
Author

I use Laravel 4.2,
Ya i have added the provider and alias, and have published the config. All your instruction to install i've followed.

here is my composer.json

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.",
"facebook/php-sdk-v4": "4.0.
",
"thujohn/twitter": "~2.0"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-0" : {
"App" : "app/src"
}
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev",
"require-dev": {
"way/generators": "~2.0"
}
}

@thujohn
Copy link
Collaborator

thujohn commented Mar 26, 2015

Can you post your code ?

@peterkocian
Copy link

I have the same problem, do you have some solution? Thank you.
ErrorException in Twitter.php line 56:
Undefined index: ttwitter::config

@thujohn
Copy link
Collaborator

thujohn commented Mar 31, 2015

Can you post your code ?

@peterkocian
Copy link

I found a mistake in my own code. It works great... Thx..

@ortix
Copy link

ortix commented Apr 21, 2015

Same problem here..

published config, providers added.. It actually used to work a while back.

My code:

    function __construct(Tweet $twitterAPI, CLImate $climate)
    {
        $this->twitterAPI = $twitterAPI;
        $this->climate = $climate;
    }

    public function fire(BeanstalkdJob $job, $data)
    {
        $this->climate->info('Posting to twitter!');
        // get args
        $ss = $data['ss'];
        $episode_id = $data['episode_id'];

        // get necessary fields
        $episode = \Episode::find($episode_id)->with('Show')->get();;
        $number = $episode->episode_number;
        $slug = $episode->show->slug;

        // generate url and message
        $url = URL::route('shows.episode.show', [$slug, $number, $episode->id]);
        $url = str_ireplace('.dev', '.com', $url);

        $message = $episode->present()->title() . ' posted! #anime #ecchi ' . $url;

        // Post media with screenshot
        if ($ss) {
            $screenshot = File::get($episode->present()->screenshot('large', true, true));
            $response = $this->twitterAPI->postTweetMedia(['status' => $message, 'media[]' => $screenshot]);
            $this->climate->info('Posted with screenshot: ' . $message);
            Log::info('Posted to twitter with screenshot!' . "\n", ['response' => $response]);
        } else {
            $response = $this->twitterAPI->postTweet(['status' => $message]);
            Log::info('Posted to twitter!' . "\n", ['response' => $response]);
        }

        // Save in database that we have posted this to twitter!
        $episode->posted_to_twitter = 1;
        $episode->save();

        $job->delete();
    }

Apparently I can't use dependancy injection? It works fine with the facade..

Also this:

[Exception]
[64] The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.

@nickdenardis
Copy link

@Ortix92 I'm encountering the same probably when trying to inject Twitter with dependency injection, works fine as a facade though.

ErrorException in Twitter.php line 56:
Undefined index: ttwitter::config

@HeathNaylor
Copy link

Same issue as @nickdenardis I had to use the Facade to use this, using dependency injection threw the

ErrorException in Twitter.php line 56:
Undefined index: ttwitter::config

@niclowe
Copy link

niclowe commented Oct 22, 2015

I had this issue also

@jfadich
Copy link

jfadich commented Nov 23, 2015

This package is simply not compatible with dependency injection, which is really unfortunate. The way around this is to use the facade.

@atymic
Copy link
Owner

atymic commented Nov 7, 2019

Closing this due to inactivity. Please let me know if you are still having an issue and i'll reopen.

@atymic atymic closed this as completed Nov 7, 2019
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

9 participants