function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
michael_hymichael_hy 

How to use the chatter API to send real time message to users

Hello guys

I have a question about the chatter.

so far, I want to use chatter rest API to sent real time message to the users.

After do some research, I know it is easy to do this on the web page

But how to do the same things from the Android app?

below link is to show how to send message from the web page.

Could anybody can help me about this. thanks so much.

 

ps: in other hand, I can use mobile app to invoke the APEX class,

Know how to send real time message in APEX class also can resolve my question.

 

send chatter message from web page

 

Best Answer chosen by Admin (Salesforce Developers) 
ChrisOctagonChrisOctagon

You can send private messages by doing a POST to

/chatter/users/me/messages

Documentation is here:

 

http://www.salesforce.com/us/developer/docs/chatterapi/Content/connect_resources_users_messages_general.htm

All Answers

ChrisOctagonChrisOctagon

You can send private messages by doing a POST to

/chatter/users/me/messages

Documentation is here:

 

http://www.salesforce.com/us/developer/docs/chatterapi/Content/connect_resources_users_messages_general.htm

This was selected as the best answer
michael_hymichael_hy
ChrisOctagon Thanks for your remind.
StringBuilder path = new StringBuilder("/services/data/" + apiVersion + "/chatter/users/me/messages");
			
JSONArray jsonArray = new JSONArray();
jsonArray.put("00590000000vqLIAAY");
jsonArray.put("00590000000vqLqAAI");
			
JSONObject jsonObject = new JSONObject();
jsonObject.put("body", "Text of the message");
jsonObject.put("recipients", jsonArray);
jsonObject.put("inReplyTo", "");

//Use the HttpPost to send request.
String resourceURI = client.getClientInfo().instanceUrl + path.toString();
HttpPost post = new HttpPost(resourceURI);
post.setHeader("Authorization", "OAuth " + client.getAuthToken());
post.setHeader("Content-Type", "application/json");
post.setEntity(new StringEntity(jsonObject.toString(), HTTP.UTF_8));
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse resp = client.execute(post);

 

michael_hymichael_hy

when I finish to send chatter message with rest api.

I still want to know how to do the same things use Apex class.

could someone can help on this?

Thomas Moore 23Thomas Moore 23
Sending SMS via chatter is possible through 360 SMS App. Kindly visit at the link- https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000DpSyIEAV or send an inquiry for quick response to- support@360degreeapps.com