adamcbrewer / twitterapi

An OAuth 1.0A library written in PHP
1 stars 2 forks source link

Swapping out twitterApi.php v1.0.0 with v1.0.1 causes it to fail #2

Closed aylacullen closed 9 years ago

aylacullen commented 9 years ago

Swapping out twitterApi.php v1.0.0 with v1.0.1 causes it to fail. Yes, I updated the appropriate info (hard-coded values at lines 62 to 66; I updated by a simple copy and paste. Swapping versions back fixed the issue.

Errors are: PHP Warning: Missing argument 1 for Twitter::initialize(), called in twitterApi.php on line 68 and defined in twitterApi.php on line 58 PHP Fatal error: Call to a member function request() on a non-object in twitterApi.php on line 396

adamcbrewer commented 9 years ago

I think the Twitter API versions only range from v1.0 to v1.1. I've checked at it looks like the code currently uses v1.1 anyway.

I think the missing argument for ::initialize() from what I can see though, good spot. Though I've not come across this before myself. I might not have time to fix this soon myself, but I really want to tidy everything up eventually.

adamcbrewer commented 9 years ago

@doncullen I've just done a cleanup of the code – I'm using composer to install the oauth stuff now. The readme file should contain everything you need to get started. Hope it helps!

adamcbrewer commented 9 years ago

@doncullen unfortunately composer is required to pull in the oauth lib used. You could download those files and put them in the directory, but composer is definitely quicker and cleaner (if your env has composer installed).

adamcbrewer commented 9 years ago

Apologies – install instruction here for composer.

Depending on where the executable is installed, you should just be able to follow the instructions in the readme of this repo. If you have any issues I'll try help out as much as I can.

aylacullen commented 9 years ago

Adam- I was able to use the oauth library without using composer. I updated the code with your changes, and got a new error:

Parse error: syntax error, unexpected 'static' (T_STATIC) in httpdocs/twitter_backend/twitter.php on line 314

Line 314 brings this code up: $return static::_response();

The full code for that section is:

    /**
     * Sending out a tweet through Twitter's oAuth API
     *
     * We can specify an ID of a message we're replying to,
     * but a reply will only be served if the status body contains
     * the username of the person/message we're replying to
     *
     * @param string $message       The tweet you want to post
     * @param sting/int $in_reply_to_status_id The ID of the message we're replying to
     */
    public static function create ( $tweet = '', $in_reply_to_status_id = false ) {

        $params = array(
            'status' => $tweet
        );

        if ( $in_reply_to_status_id !== false ) {
            $params['in_reply_to_status_id'] = $in_reply_to_status_id;
        }

        static::api()->request('POST', static::api()->url('1.1/statuses/update'), $params);

        $return static::_response();

    }

I regressed the code back to the previous version, and it's working fine now. Any ideas?

adamcbrewer commented 9 years ago

@doncullen I realise there's a syntax error on that line – there shouldn't be a dollar sign before return. Take a look.

Try removing that dollar sign and see if you still get errors?

aylacullen commented 9 years ago

No further errors. Working fine.

You may want to fix line 314 so others won't run into it when they download and use it.

Thanks for working with me!

Regards,

Don Cullen

Disclaimer: Anything I say in this email represent myself, and do not

represent my employer.

On Wed, Sep 23, 2015 at 12:06 PM, Adam Brewer notifications@github.com wrote:

@doncullen https://github.com/doncullen I realise there's a syntax error on that line – there shouldn't be a dollar sign before return. Take a look https://github.com/adamcbrewer/twitterapi/blob/master/twitterApi.php#L314 .

Try removing that dollar sign and see if you still get errors?

— Reply to this email directly or view it on GitHub https://github.com/adamcbrewer/twitterapi/issues/2#issuecomment-142649385 .

adamcbrewer commented 9 years ago

Pleasure – the issue should be fixed now!