【问题标题】:Links posted on Facebook page do not show upFacebook 页面上发布的链接不显示
【发布时间】:2013-02-15 08:02:43
【问题描述】:

我正在开发一个需要在 Facebook 页面上自动发布链接的小模块。 我已经完成了以下设置:

  • 创建了一个 Facebook 页面(将显示链接的页面)
  • 创建了一个 Facebook 应用
  • 在页面管理员个人资料以及 Facebook 页面上添加了具有以下权限的应用程序:publish_stream、manage_pages

为了获得有效的访问令牌(暂时手动 - 我知道不推荐这样做,但在我的情况下它可以完成工作)我做了以下工作:

  1. 以页面管理员身份登录
  2. 导航到页面:https://developers.facebook.com/tools/access_token/
  3. 复制用户令牌并通过 GET-ting 以下 url 使其非瞬态:https://graph.facebook.com/oauth/access_token?client_id={app id}&client_secret={app secret}&grant_type=fb_exchange_token&fb_exchange_token ={我之前复制的令牌}
  4. 通过将 GET 发送到:https://graph.facebook.com/me/accounts?access_token={永不过期的访问令牌}
  5. ,从第 3 步产生的用户令牌中获取页面访问令牌

从我在第 4 步之后获得的 json 中复制我感兴趣的页面的访问令牌并使用以下 C# 代码发布链接:

try
        {
            dynamic data = new ExpandoObject();

            var fbm = message as FacebookMessage;

            data.access_token = ConnectionData.AuthenticationToken;
            data.message = fbm.Message;
            data.link = fbm.Link;
            data.name = fbm.Name;
            data.caption = fbm.Caption;
            data.description = fbm.Description;
            if (!String.IsNullOrEmpty(fbm.Icon))
            {
                data.picture = fbm.Icon;
            }
            var @params = ((ExpandoObject)data).ToUrl();

            var _currentRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(String.Format("https://graph.facebook.com/{0}/feed?{1}", _currentEndpoint.ObjectID, @params));
            _currentRequest.Method = "POST";
            _currentRequest.ContentType = "application/json; charset=utf-8";
            _currentRequest.UserAgent = "Mozilla/4.0 (compatible; Windows NT)";
            _currentRequest.Accept = "*/*";
            _currentRequest.CookieContainer = new CookieContainer();
            _currentRequest.KeepAlive = false;
            //_currentRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

            //using (var sw = new StreamWriter(_currentRequest.GetRequestStream(), Encoding.UTF8))
            //{
            //    sw.Write(json);
            //}

            string json;
            var resp = _currentRequest.GetResponse();

            using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
            {
                json = sr.ReadToEnd();
            }

            var jsonSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            var output = jsonSerializer.Deserialize<dynamic>(json);

            return new OperationStatus();
        }
        catch (Exception ex)
        {
            return new OperationStatus { Exception = ex };
        }
    }

“_currentEndpoint.ObjectID”是页面的对象 ID。 POST 已成功完成,只要我以管理员身份登录,我就会看到链接发布在管理员的墙上以及页面本身上。 我越早退出,我就看不到任何发布的链接,也看不到任何喜欢该页面的人。

什么给了?如何使链接显示在页面墙上以及喜欢该页面的人的墙上。 我确实检查了页面上的垃圾邮件,但我在那里看不到我的链接,而且从隐私设置来看,一切似乎都是可见的。

【问题讨论】:

    标签: c# facebook-graph-api hyperlink posting


    【解决方案1】:

    阅读这篇文章后:Posting a link to a page not showing up? 我终于启动并运行了它。问题似乎出在访问令牌上,但我仍然没有弄清楚出了什么问题: 这是我最后所做的:

    这似乎为我提供了向页面墙上的每个人发布可见链接所需的访问令牌。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 2016-07-23
      相关资源
      最近更新 更多