58web3 / drawww

0 stars 0 forks source link

Twitter context contains text and image #38

Open hanchenglin opened 2 years ago

hanchenglin commented 2 years ago

Problem

Now twitter content only contains a image url!

Evidence

Image

Bugfix

Image

hanchenglin commented 2 years ago

get acccess token source sample, I will continue to investigate

## Twitter
TWITTER_API_URL=https://api.twitter.com
TWITTER_REQUEST_URL=https://api.twitter.com/oauth/request_token
TWITTER_AUTHORIZE_URL=https://api.twitter.com/oauth/authorize
TWITTER_ACCESS_URL=https://api.twitter.com/oauth/access_token
CONSUMER_KEY=VLZT80Yc0KJG6xlgGmbVrdy8L
DRAWWW_APP_URL=http://localhost:3000
async loginTwitter() {
      const requestURL = process.env.TWITTER_REQUEST_URL + 
      "?oauth_consumer_key=" + process.env.CONSUMER_KEY +
      "&oauth_callback=" + encodeURIComponent(process.env.DRAWWW_APP_URL);

      console.log(requestURL)
      const res1 = await axios.get(requestURL);
      console.log(res1.data)

      const authorizeURL = process.env.TWITTER_AUTHORIZE_URL + "?oauth_token=" + res1.data.oauth_token
      console.log(authorizeURL)
      const res2 = await axios.get(authorizeURL);
      console.log(res2.data)

      const accessURL = process.env.TWITTER_ACCESS_URL + 
      "?oauth_token=" + res1.data.oauth_token +
      "&oauth_verifier=" + res1.data.oauth_verifier +
      "&oauth_consumer_key=" + process.env.CONSUMER_KEY;
      console.log(accessURL)
      const res3 = await axios.post(accessURL, {});
      console.log(res3.data)
    }

Now, has a CORS error, should use Apache httpd for call API?

hanchenglin commented 2 years ago

@minhtuan412 Please implement post twitter with text and image(do not only a url)