spring-attic / spring-social-twitter

Twitter API binding and connect support.
http://projects.spring.io/spring-social-twitter
Apache License 2.0
122 stars 114 forks source link

help me... (On September 17th, 2018 we retired the legacy Direct Message endpoints.) #127

Open flyyou opened 5 years ago

flyyou commented 5 years ago

I am sending twitter using this library. But the direct message is a retired endpoint.

Thank you for updating the library. https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/guides/direct-message-migration

===================== Direct Message migration guide On September 17th, 2018 we retired the legacy Direct Message endpoints. If you had been using those endpoints, please make sure to migrate over to the new Direct Message endpoints or the Account Activity API. Please review this announcment to learn more.

This guide is designed to help you migrate from legacy Direct Message REST APIs to their enhanced replacements which have graduated from beta. Below you will find a summary of the changes, a new features list, and key differences and considerations to help with the transition. The new Direct Message endpoints are available now to all developers. For guidance in migrating from User Streams or Site Streams, see the migration guide to Account Activity API.

flyyou commented 5 years ago

Wire.java:72) http-outgoing-0 >> "POST /1.1/direct_messages/new.json HTTP/1.1[\r][\n]" Wire.java:72) http-outgoing-0 >> "Accept: application/json, application/*+json[\r][\n]" Wire.java:72) http-outgoing-0 >> "Content-Type: application/x-www-form-urlencoded[\r][\n]" Wire.java:72) http-outgoing-0 >> "Authorization: OAuth oauth_nonce="~~", oauth_token="~~", oauth_consumer_key="~~", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1537346328", oauth_version="1.0", oauth_signature="~~"[\r][\n]" Wire.java:72) http-outgoing-0 >> "Content-Length: 100[\r][\n]" Wire.java:72) http-outgoing-0 >> "Host: api.twitter.com[\r][\n]" Wire.java:72) http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" Wire.java:72) http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_151)[\r][\n]" Wire.java:72) http-outgoing-0 >> "Cookie: lang=en[\r][\n]" Wire.java:72) http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" Wire.java:72) http-outgoing-0 >> "[\r][\n]" Wire.java:86) http-outgoing-0 >> "screen_name=~~&text=AIC+%7C+FAILED%7C17%3A38%3A43.735%7CDo+PeerToPeer%7CNo+response+from+peer" ### Wire.java:72) http-outgoing-0 << "HTTP/1.1 404 Not Found[\r][\n]"** Wire.java:72) http-outgoing-0 << "cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0[\r][\n]" Wire.java:72) http-outgoing-0 << "content-disposition: attachment; filename=json.json[\r][\n]" Wire.java:72) http-outgoing-0 << "content-encoding: gzip[\r][\n]" Wire.java:72) http-outgoing-0 << "content-length: 93[\r][\n]" Wire.java:72) http-outgoing-0 << "content-type: application/json;charset=utf-8[\r][\n]" Wire.java:72) http-outgoing-0 << "date: Wed, 19 Sep 2018 08:38:47 GMT[\r][\n]" Wire.java:72) http-outgoing-0 << "expires: Tue, 31 Mar 1981 05:00:00 GMT[\r][\n]" Wire.java:72) http-outgoing-0 << "last-modified: Wed, 19 Sep 2018 08:38:47 GMT[\r][\n]" Wire.java:72) http-outgoing-0 << "pragma: no-cache[\r][\n]" Wire.java:72) http-outgoing-0 << "server: tsa_m[\r][\n]" Wire.java:72) http-outgoing-0 << "set-cookie: personalization_id="~~"; Expires=Fri, 18 Sep 2020 08:38:47 GMT; Path=/; Domain=.twitter.com[\r][\n]" Wire.java:72) http-outgoing-0 << "set-cookie: guest_id=~~; Expires=Fri, 18 Sep 2020 08:38:47 GMT; Path=/; Domain=.twitter.com[\r][\n]" Wire.java:72) http-outgoing-0 << "status: 404 Not Found[\r][\n]" Wire.java:72) http-outgoing-0 << "strict-transport-security: max-age=631138519[\r][\n]" Wire.java:72) http-outgoing-0 << "x-access-level: read-write-directmessages[\r][\n]" Wire.java:72) http-outgoing-0 << "x-connection-hash: f79fd78d28e7603861938162a0085190[\r][\n]" Wire.java:72) http-outgoing-0 << "x-content-type-options: nosniff[\r][\n]" Wire.java:72) http-outgoing-0 << "x-frame-options: SAMEORIGIN[\r][\n]" Wire.java:72) http-outgoing-0 << "x-response-time: 109[\r][\n]" Wire.java:72) http-outgoing-0 << "x-transaction: 007329bd00bb8249[\r][\n]" Wire.java:72) http-outgoing-0 << "x-tsa-request-body-time: 0[\r][\n]" Wire.java:72) http-outgoing-0 << "x-twitter-response-tags: BouncerCompliant[\r][\n]" Wire.java:72) http-outgoing-0 << "x-xss-protection: 1; mode=block; report=https://twitter.com/i/xss_report[\r][\n]" Wire.java:72) http-outgoing-0 << "[\r][\n]"

paweljarosz83 commented 5 years ago

I thought nobody is using Spring Social anymore since there's almost no disscusion here. I assume you actually can sign in with Twitter to send a DM? What callback_url did you whitelist on Apps Twitter to run on localhost?

flyyou commented 5 years ago

Yeah I am running TwitterProxy on localhost.

private TwitterProxy() { twitter = new TwitterTemplate("~~", "~~", "123452878-~~", "~~"); }

public void SendDirectMessage(String message) { String list = Settings.INSTANCE.getProperty("testDaemon.alert.list", "~~~~");

    if(message.length() >= 140) {
        message = message.substring(0, 139);
    }

    String[] items = list.split(",");

    for(String item : items) {
        twitter.directMessageOperations().sendDirectMessage(item, message);
    }
}

========================================== However, I received the following response. HTTP / 1.1 404 Not Found [\ r] [\ n]

Please help me ~ Please.

ravisankart commented 5 years ago

Hi, Looks like the link for Direct Message Migration is broken. Is there a latest version of spring-social-twitter libraries that would address the problem of using retired end points. broken : https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/guides/direct-message-migration. Please advise.

paweljarosz83 commented 5 years ago

Hi, I incorparated Twitter4J into the Spring Social project as a dependency. I already have all credentials required to authorize, so I create Twitter4J instance with them and use it for DM. For the rest I still use Spring Social.