getDirectMessages method is not returning the values


#1

Hi,

Im trying to retrieve direct messages using the REST API method getDirectMessages, but im getting empty response. When i call the josn in postman “/1.1/direct_messages/events/list.json” it works but using the proxy file it doesn’t work. Can someone please help me.

<?xml version="1.0" encoding="UTF-8"?>




<twitter.init>


********
*******
</twitter.init>
<twitter.getDirectMessages>
100
</twitter.getDirectMessages>

var payload = mc.getPayloadJSON();
var Messages = payload;
var response = new Array();

		for (i = 0; i &lt; Messages.length; ++i) {
			Message = Messages[i];
			messageObject = new Object();
			messageObject.date_time = Message.created_at;
			messageObject.channel_message = Message.text.replace(/[^a-zA-Z 0-9]/g, "");
			messageObject.channel_message_ID = Message.id_str;
			messageObject.channel_thread_id = Message.sender.id_str;
			messageObject.channel_ID = Message.sender.id_str;
			messageObject.created_by = Message.sender.screen_name;
			response[i] = messageObject;
		}
		mc.setPayloadJSON(response);
	</script>
    <property name="messageType" scope="axis2" value="application/json"/>
		<send>
			<endpoint>
				<http method="POST" uri-template="http://localhost:3000/api/message"/>
			</endpoint>
     </send>
     <respond/>
  </inSequence>
```

#2

What programming environment is this? This does not look like code supplied by Twitter.


#3

Hi Andy,

We are using WSO2 ESB(Enterprise Service Bus) in order to manipulate the response as per business requirements. It uses twitter connector zip file which actually contains the twitter API methods. In <twitter.init> section we pass the required access tokens and the <twitter.getDirectMessages> actually calls the API method. The javascript to manipulate the output.

Thanks,
Shanthi


#4

Now i see, the below error though i was using id_str instead of id.

{“errors”:[{“code”:34,“message”:“Sorry, that page does not exist.”}]}

Did anything changed as part of Direct messages API ?


#5

Looks like that connector was patched for the new API format a couple of months ago https://github.com/wso2-extensions/esb-connector-twitter/commit/7ce95ba58aa18947b545cb65560f0547312b924f


#6

Yes, you are right ! We were using the older version of connector and few methods are now deprecated. We no need to call getSentDirectMessages and just getDirectMessages would be sufficient to receive all the direct messages both sent and received. After removing the unnecessary call backs it’s working again now. Thank you so much for the information provided.

Best Regards,
Shanthi


#7

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.