java - How to use Facebook Messenger API? -


i writing java application in need access chat history (chat messages between me , facebook friend). have looked @ this link, seems outdated since have noticed facebook changed messenger api significantly. wondering if still possible access message history via java.

p.s. found facebook graph api called restfb. not able find such api chat messages.

you can use inbox resource of graph api: https://developers.facebook.com/docs/graph-api/reference/v2.3/user/inbox

edit:

in order use java, you'll need first follow login instructions @ https://developers.facebook.com/docs/facebook-login/v2.3 . that's large enough operation i'm going assume you've done -- it's outside scope of answer (but i'm sure there other questions handle sufficiently on stackoverflow if look).

once have access token particular session (you can 1 test going https://developers.facebook.com/docs/graph-api/reference/v2.3/user/inbox, clicking graph explorer button, clicking "get token" -> "get access token", , ensuring "read_mailbox" selected under "extended permissions), it's pretty straightforward read api. can using standard jdk classes in few lines:

    string accesstoken = "replacethiswithaccesstoken";     string urlstring = messageformat.format("https://graph.facebook.com/v2.3/me/inbox?access_token={0}&&format=json&method=get",             accesstoken);     url url = new url(urlstring);     bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(url.openstream()));     string line;     while ((line = bufferedreader.readline()) != null) {         system.out.println(line);     }     bufferedreader.close(); 

this glosses on lot of things -- doesn't authentication, assumes active trust store contains certification path facebook ssl cert (it should), , ignore proper error handling. , in practice you'll want use restclient or similar instead of using url directly -- above should indicative of need do.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -