FbGraph2并获得公司网站的帖子

时间:2017-12-11 10:12:58

标签: ruby-on-rails facebook-graph-api fb-graph

我有问题从Facebook上的公司简介(网站)发帖。 我使用fb-graph2 gem

page = FbGraph2::Page.new(fb_page).authenticate(fb_access_token)
        feed = page.fetch.feed

但问题是这个脚本从墙上获取所有帖子 - 由公司(网站)所有者编写的帖子和普通用户发布的帖子。你能只下载所有者网站写的帖子吗?

1 个答案:

答案 0 :(得分:0)

public static void main(String[] args) throws MessagingException{
    String host = "smtp.gmail.com", senderid = "<sender_id>@gmail.com", recipient = "<recipient_id>@gmail.com";
    String password = "*******";
    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", "587");

    // Get the Session object.
    Session session = Session.getInstance(props,
    new javax.mail.Authenticator() {
       protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication(senderid, password);
       }
    });

    System.out.println("Sending mail");

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(senderid));
    message.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(recipient));
    message.setSubject("Test");

    message.setContent(<table_format stored a string which accesses the count variable in its <td> tag>, "text/html");
    Transport.send(message);

    System.out.println("Done");

}

这将返回带有作者ID的Feed中的帖子,您可以检查它是否与所有者ID相同。