1

I received an email saying my use of the Twitter API v1.1 was being suspended. I went into my dev account and switched my app to the free tier to unsuspend it but now I'm having trouble posting tweets.

If I understand correctly, API v1.1 doesn't support posting tweets using the free tier. If I use API v2 to execute a POST, I receive a 401 Unauthorized. I've tried using both Oauth 1.0 and Oauth 2.0 with the same result. Sample code using an Oauth library is below.

OAuthRequest client = OAuthRequest.ForProtectedResource("POST", [ConsumerKey], [ConsumerSecret], [AccessToken], [AccessTokenSecret]);
            client.RequestUrl = "https://api.twitter.com/2/tweets";
            string auth = client.GetAuthorizationHeader();

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(client.RequestUrl);
            request.Method = "POST";
            request.ContentType = "application/json";
            request.Headers.Add("Authorization", auth);
            using (var streamWriter = new StreamWriter(request.GetRequestStream()))
            {
                streamWriter.Write("{\"text\":\"Hello.\"");
            }
            var response = (HttpWebResponse)request.GetResponse();
            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
kittyhawk
  • 688
  • 2
  • 11
  • 25
  • You aren't doing anything wrong. Twitter's API either isn't working or someone hasn't updated your account yet. Keep bugging their support and eventually it will get resolved. – Bron Davies Jul 21 '23 at 14:47
  • 1
    I don't know how I can even contact Twitter and get a response. I've been "pending" approval on their support forum for a week and I see no way to send them a direct message. My account isn't suspended anymore so I can't go that route. At this point, there's really no way to get my application working again that I can see. We have critical, emergency management information that we are trying to get out the public and Twitter has just decided to hang us out to dry. – kittyhawk Jul 21 '23 at 16:53

0 Answers0