I want to verify if it is a valid Twitter URL.

Asked 2 years ago, Updated 2 years ago, 60 views

Current State
Based on the tweet URL entered by the user, one tweet was retrieved (on Twitter API).
Using bearer tokens with linked

What do you want to do
I would like to verify if it is a valid Twitter URL when the user enters it.
My intention is to prevent meaningless URL entry.

What I don't know
How do you determine if it is a valid Twitter URL?
Can't you do a complete validation check before requesting it?

  • Proposal 1.Determine if it is in the following URL format
    Use regular expressions in JavaScript?

    https://twitter.com/xxxx/status/xxxx

  • Proposal 2. After requesting below, determine if the HTTP response status code is 200?
    Using PHP?

    GET states/show/:id

  • Do you have any other suggestions?

Proposition 1. Decide by whether it is in the following URL format
Use regular expressions in JavaScript?

https://twitter.com/xxxx/status/xxxx

Proposition 2. After requesting the following, is it determined by whether the HTTP response status code is 200?
Using PHP?

GET states/show/:id

Do you have any other ideas?

javascript php regular-expression twitter

2022-09-29 22:00

1 Answers

Twitter is publishing the API Specification.
https://developer.twitter.com/en/docs/labs/overview/introduction.html

I think I can create a client with Codegen for PHP and validate it by whether the client can receive parameters (no exceptions).
https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/php/SwaggerClient-php

There are other ways to do this.


2022-09-29 22:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.