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

Migrate to Twitter API v2 #229

Merged
merged 24 commits into from
May 16, 2023
Merged

Migrate to Twitter API v2 #229

merged 24 commits into from
May 16, 2023

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Apr 28, 2023

Description of the Change

PR migrates the current Twitter API implementation to use API v2. Majorly PR has made the below changes

  • Migrated to Twitter API v2
  • Add migrate to v2 notice for only existing users
  • Update app setup steps to the latest process
  • Added learn more link to error message for old credentials user

Closes #173

How to test the Change

Follow the steps mentioned on the Autoshare for Twitter Settings admin page and set up the Twitter app. You should be able to set up the plugin without struggle. After saving the plugin setting with the Twitter app details, you should be able to tweet from WordPress from the post edit page.

  1. Make sure the plugin works fine with Twitter API v2
  2. Verify plugin shows notice about migrating to v2 to existing users
  3. Error message to existing v1.1 API users while tweet post.

Changelog Entry

Added - Support for Twitter API v2.
Changed - Update plugin settings and guidelines to set up a Twitter app.

Credits

Props @iamdharmesh, @qasumitbagthariya, @ravinderk, @jeffpaul.

Noticeable changes

  • Add PHP dependency to 7.4 in composer.json

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@iamdharmesh iamdharmesh self-assigned this Apr 28, 2023
@iamdharmesh iamdharmesh added this to the 1.4.0 milestone Apr 28, 2023
@ravinderk
Copy link
Contributor

@iamdharmesh For some reason, E2E tests are failing. This pull request does not change anything related to UI/UX. Do you know if these tests are falling correctly?

@iamdharmesh
Copy link
Member Author

@ravinderk I have reverted app setup instructions as we discussed internally on call, Also tests seems failing due to credentials currently setup in repo secret is not migrated to Twitter API V2 yet.

Thanks

@jeffpaul
Copy link
Member

@iamdharmesh I added the *_V2 repo secrets and then updated the cypress workflow, but still seems to have some failures. Could you please check those?

@jeffpaul
Copy link
Member

Let's update the sidebar error from:

Failed to tweet: Error: . <Twitter error here>

to:

Failed to tweet; error: <Twitter error here>

...also, if the Twitter error is the "When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal." (hopefully there's an error code we can target in case they change that copy) then let's please add after the Twitter error message "Learn more here." and link to https://developer.twitter.com/en/docs/twitter-api/migrate/ready-to-migrate.

...which means in this case that would be like:

Failed to tweet; error: <Twitter error here> Learn more here.

@jeffpaul
Copy link
Member

On the Settings page, update all references existing to match spelling/case of:

  • API Key
  • API Key Secret
  • Access Token
  • Access Token Secret

...this way we match the exact same spelling/case/wording used on https://developer.twitter.com to avoid user confusion on configuring the plugin.

@jeffpaul
Copy link
Member

Let's update the admin notice to:
Autoshare for Twitter now utilizes the Twitter v2 API. If you have not already done so, please migrate your app to Twitter v2 API to continue using Autoshare for Twitter. Learn more about migrating here.

@jeffpaul
Copy link
Member

@iamdharmesh the above couple updates should bring this PR to a good point for final review/merge... thanks!

@jeffpaul jeffpaul mentioned this pull request May 11, 2023
17 tasks
@iamdharmesh
Copy link
Member Author

Failed to tweet: Error: . <Twitter error here>

@jeffpaul Currently we are also showing an error code in this message. for eg: Error: 429. Too Many Requests. (dot there looks extra due to no error code) So, should we keep it showing the error code OR it is no longer needed?

@jeffpaul
Copy link
Member

If there's no code then let's not display the "Error: ." bit, if there is a code then we can keep that wrapping text.

@iamdharmesh iamdharmesh changed the title [WIP] Migrate to Twitter API v2 Migrate to Twitter API v2 May 15, 2023
@iamdharmesh
Copy link
Member Author

@iamdharmesh I added the *_V2 repo secrets and then updated the cypress workflow, but still seems to have some failures. Could you please check those?

It failed due to the API limit was exceeded for 24 hours.

@iamdharmesh iamdharmesh marked this pull request as ready for review May 15, 2023 10:24
@iamdharmesh iamdharmesh requested a review from a team May 15, 2023 10:24
@github-actions github-actions bot added the needs:code-review This requires code review. label May 15, 2023
@jeffpaul jeffpaul requested review from a team and removed request for a team May 15, 2023 15:53
Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! I've requested some minor changes, after that it's good to go 🎉

__FILE__,
function () {
// Don't need to show migration notice to new users.
update_option( 'migrate_to_twitter_v2_api_notice_dismissed', true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nitpick here - will be good to prefix the option with autoshare_

@@ -317,7 +317,7 @@ function get_tweet_status_message( $post ) {

case 'error':
$response_array[] = [
'message' => __( 'Failed to tweet: ', 'autoshare-for-twitter' ) . $tweet_meta['message'],
'message' => __( 'Failed to tweet; ', 'autoshare-for-twitter' ) . $tweet_meta['message'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? Colon : would be appropriate here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sidsector9 it is updated as per the request here #229 (comment)

Copy link
Contributor

@ravinderk ravinderk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamdharmesh I left a few questions.

@iamdharmesh iamdharmesh merged commit 9b159dc into develop May 16, 2023
@iamdharmesh iamdharmesh deleted the migrate-v2 branch May 16, 2023 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check if plugin can work with only Essential access
4 participants