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

Created on 6 October 2023, over 1 year 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

Active

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 10 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & sqlite-3.27
    last update 10 months ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium mschudders

    I tested this and it works.

    Moving to needs review

  • πŸ‡¨πŸ‡¦Canada mahde Vancouver

    I was getting the following error while trying to add account in the user profile page and this patch fixed it!

    TypeError: Drupal\social_api\User\UserManager::getDrupalUserId(): Argument #1 ($provider_user_id) must be of type string, null given, called in /var/www/html/web/modules/contrib/social_post_twitter/src/Controller/TwitterPostController.php on line 189 in Drupal\social_api\User\UserManager->getDrupalUserId() (line 89 of /var/www/html/web/modules/contrib/social_api/src/User/UserManager.php).

  • πŸ‡ΊπŸ‡¦Ukraine proweb.ua

    #4 the same situation

Production build 0.71.5 2024