Response issue POST statuses/update


#1

I’m having an issue while sending DMs over the REST 1.1 API. Though the DM will send and the recipient gets it correctly, the response i get from the API is not as expected. I’m recieving the JSON of my most recent public tweet back rather than the DM i just sent. I’m using the PHP TwitterAPIExchange plugin and my code is below. Has anyone else experienced this?

function sendDMTweet($settings,$tweetText,$twitterHandle)
 {
     $url = 'https://api.twitter.com/1.1/statuses/update.json';
     $postfields = array(
     'status' => 'D '.$twitterHandle.' '.$tweetText, 
     );

     $requestMethod = 'POST';
     $twitter = new TwitterAPIExchange($settings);
     $resultsFromTwitterAPI = $twitter->setPostfields($postfields)
                  ->buildOauth($url, $requestMethod)
                  ->performRequest();
         
         return $resultsFromTwitterAPI;
 }

#2

I’m guessing this is because you are sending a DM (using the ‘D [user] [message]’ syntax?) over the statuses/update endpoint.

If you were to use direct_messages/new instead then I would expect the response not to contain your most recent public Tweet.


#3

I will give that a try instead, thanks for the hint. Will post if this resolves the issue.