如果我具有消息ID,如何构造链接以在facebook.com上查看消息 [英] How can I construct a link to view a message on facebook.com if I have the message id

查看:106
本文介绍了如果我具有消息ID,如何构造链接以在facebook.com上查看消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过以下图形api调用来检索消息传递收件箱:

I am retrieving the messaging inbox with the following graph api call:

https://graph.facebook.com/me/inbox?access_token=...

它返回一组消息,每个消息都有一个标识"id"(与FQL返回的消息id相同)

It returns an array of messages that each have an identifying "id" (same as message id as returned by FQL)

我希望能够提供一个链接,以便用户直接在Facebook.com上查看消息.

类似的东西: https://www.facebook.com/messages/? action = read& tid = ....

Something like: https://www.facebook.com/messages/?action=read&tid=....

如果您浏览来自Facebook本身的消息,则将获得该链接.

That is the link you get to if you you browse to a message from facebook itself.

但是我似乎找不到从Graph API或FQL发现正确提示的方法.

However I can't seem to find a way to discover the correct tid from either the Graph API or FQL.

我也没有找到一个替代URL的运气.

I haven't had any luck in figuring out an alternative URL either.

该网址曾经可以使用,但现在对我来说是无效的: http://facebook.com /?sk = messages& tid = ...

This url used to work, but is broken for me now: http://facebook.com/?sk=messages&tid=...

它仅重定向到顶级消息传递页面: https://www.facebook.com/messages/

It just redirects to the top level messaging page: https://www.facebook.com/messages/

有任何想法吗?

非常感谢

推荐答案

从图形API到me/inbox,结果集给出id作为返回的每个对象的一部分.这也是thread_id.

From graph API get to me/inbox the result set gives id as part of each object returned. This is also thread_id.

如果您拥有的ID是一个字符串对象(可能是一个GUID),则来自Facebook的旧消息系统存储结构.现在,他们已更新到新的存储结构,该结构要求将旧的存储结构迁移到新的存储结构

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:

如果线程ID较长(Int64/BigInt),则您有一个新线程,可以使用 http://www.facebook.com/messages/?action=read&tid=id.THREAD_ID

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

如果线程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;

这篇关于如果我具有消息ID,如何构造链接以在facebook.com上查看消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆