Authentication works but profile isnt returned 404, Warning: Attempt to read property "id" on null in

Created on 6 October 2023, 12 months ago
Updated 28 March 2024, 6 months ago

Oauth works fine goes off to twitter comes back and authentication all works fine, but when it tries to call
$profile = $client->get("account/verify_credentials", $params);
a 404 is returned and without the profile data account not setup.
line 185 in TwitterPostController.php It sort of feels like maybe twitter has disabled the profile API call or removed it? Or maybe I need to enable this within twitters API but couldn't find it. Defo on an app in a project and have access to API 2. Any help would be great feel like I am close. Thanks

🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom zarexogre

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @zarexogre
  • 🇬🇧United Kingdom zarexogre

    Figured this out wasnt easy. First you need to create an app within a project on twitter dev portal to get access to v2 apis.

    Then there were 2 issues with the code.

    First, the API call for getting profile data from twitter is v1.1 but the code is trying v2 which doesn't have this API call hence the 404.

    Second, the tweet API call is to update status which seems to have gone, v2 has a free tweet API call so using that.

    Now its working great. Docs could do with some love all very complicated.

    Patch attached.

  • Status changed to RTBC 6 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & sqlite-3.27
    last update 6 months ago
    3 pass
  • 🇧🇪Belgium Mschudders

    I tested this and it works.

    Moving to needs review

Production build 0.71.5 2024