How can I capture Direct Message via Instagram API?

天涯浪子 提交于 2020-07-05 03:07:11

问题


I searched the api instagram if there is any method to return the direct messages, and found nothing. Can you tell if there is something, or if it is not possible? Instagram does not offer? Or I can do programmatically? I need capture direct message, is possible?


回答1:


There is no Instagram API for direct messages, and since it's been almost 4 years now, I guess there won't be any. You may be able to use the Instagram node.js Private API library or the Instagram PHP Private API library.

I have to warn you though, that I did try to use the PHP library and Instagram didn't allow sending of direct messages, no matter how much hacking I tried to make it work. But maybe this was just me...

If you are able to use node.js, it seems that Thread.configureText can be used for sending direct messages on the node.js library.




回答2:


string status_DM = string.Empty;
string Url_DirectMessage = "https://i.instagram.com/api/v1/direct_v2/threads/broadcast/text/";
string guid = obj_InstaUser.guid;
string userID = string.Empty;  // put user id to whom you want to send message

string responce = obj_new.getHtmlfromUrl(new Uri("https://www.instagram.com/" + username));

if(string.IsNullOrEmpty(userID))
{
    userID = Utils.getBetween(responce, "profilePage_", "}").Replace(" ","").Replace("\"","");
}
try
{
    string postData = "recipient_users=%5B%5B%22" + userID + "%22%5D%5D&client_context=%22" + guid + "%22&text=" + text + "&thread_ids=%5B%220%22%5D";
    try
    {
        string  Finalresult = obj_InstaUser.globusHttpHelperMobile.postFormDataMobileLogin_Directmessage(new Uri(Url_DirectMessage), postData);

        status_DM = "Success";
    }
    catch (Exception ex)
    {

        status_DM = "Fail";
    }
}
catch(Exception ex)
{

}



回答3:


Use Instagram private API. Through this you are able to send Direct message. I did in C# and that worked perfectly. (Direct message and upload post as well.)



来源:https://stackoverflow.com/questions/37957817/how-can-i-capture-direct-message-via-instagram-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!