How to get message thread URL knowing the thread i

2019-04-29 13:52发布

There is How can I construct a link to view a message on facebook.com if I have the message id question, but it is unanswered. What if I got the id of the thread using /me/inbox API endpoint and need to redirect user to the Facebook itself showing this thread? How do I construct the URL. There seem to be URLs like http://www.facebook.com/messages/?action=read&tid=id.143666952390138 where thread id is the number in the end. But there are also some stranger URLs like http://www.facebook.com/messages/?action=read&tid=27726d81656e4c07ae5654116cccb724 where the previous rule doesn't work. Is there any solution to getting thread URL using Graph API or FQL?

1条回答
Fickle 薄情
2楼-- · 2019-04-29 14:14

If the id you have is a string object (probably a guid), this is from Facebook's older message system storage structure. Now they've updated to a new storage structure that requires the old ones to be migrated into the new

So you have a fairly easy check:

If thread id is a long (Int64/BigInt), then you have a new thread and can use http://www.facebook.com/messages/?action=read&tid=id.THREAD_ID

If thread id is a string then you have a older thread and can use

http://www.facebook.com/messages/?action=read&tid=THREAD_ID

many programming languages have their own form of checking the type of a value.

var threadId = (string)data.thread_id;
var longVal = 0L;    
var isLong = Int64.TryParse(threadId, out longVal);
var threadUrl = (isLong) ? 
  "http://www.facebook.com/messages/?action=read&tid=id." + threadId :
  "http://www.facebook.com/messages/?action=read&tid=" + threadId;
查看更多
登录 后发表回答