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

twitter postTwitter method doesn't work in laravel 9 #399

Closed
DavidAmirKham opened this issue Sep 13, 2022 · 1 comment
Closed

twitter postTwitter method doesn't work in laravel 9 #399

DavidAmirKham opened this issue Sep 13, 2022 · 1 comment
Assignees

Comments

@DavidAmirKham
Copy link

I configured the following steps but make error postTweet method of laravel 9.
Error: Call to undefined method Atymic\Twitter\Service\Accessor::postTweet()

  1. composer require atymic/twitter

  2. php artisan vendor:publish --provider="Atymic\Twitter\ServiceProvider\LaravelServiceProvider"

  3. php artisan vendor:publish --provider="Atymic\Twitter\ServiceProvider\LaravelServiceProvider"

use Atymic\Twitter\Facade\Twitter;
public function tweet()
Twitter::postTweet(['status' => 'Laravel is beautiful', 'response_format' => 'json']);
}

@reliq reliq self-assigned this Sep 21, 2022
@reliq
Copy link
Collaborator

reliq commented Sep 21, 2022

Hi @DavidAmirKham. The postTweet method is not currently explicitly implemented for Twitter API v2.

You can however still post a tweet with API v2 in the following way:

// ...

use Atymic\Twitter\Contract\Http\Client;

// ...

$querier = Twitter::forApiV2()->getQuerier();
$result = $querier->post(
    'tweets', 
    [
        Client::KEY_REQUEST_FORMAT => Client::REQUEST_FORMAT_JSON,
        'text' => 'my tweet'
    ]
);

// ...

NB. call to forApiV2() is optional.

$result will contain the posted tweet:

image


As shown in the readme the postTweet() function is only available for API v1 at this time.

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

2 participants