Ejemplo n.º 1
0
  @Override
  protected Object doExecute() throws Exception {
    final FacebookManager facebookMgr = getBean(FacebookManager.class);
    final EntityLookup<FacebookAccessible, String> lookup =
        getBean(EntityLookup.class, FacebookRelated.class);

    Preconditions.checkArgument(
        id != null || accessToken != null, "Either id or access token must be specified.");

    final String realToken;
    if (id != null) {
      final FacebookAccessible facebookAccessible =
          Preconditions.checkNotNull(lookup.findOne(id), "Cannot find '%s' using %s", id, lookup);
      realToken = facebookAccessible.getFacebookAccessToken();
    } else {
      realToken = accessToken;
    }

    final DefaultFacebookClient facebook = new DefaultFacebookClient(realToken);
    final String connection = objectId + "/likes";
    final String abbrToken = StringUtils.abbreviateMiddle(realToken, "…", 15);
    log.debug("Deleting like to Facebook {} using {}", connection, abbrToken);
    System.out.print(
        ansi().render("Unliking @|bold %s|@ using @|yellow %s|@", connection, abbrToken));
    final boolean deletedLike = facebook.deleteObject(connection);
    System.out.println(ansi().render(" @|bold %s|@", deletedLike));
    log.info("Deleted like {} to Facebook {}", deletedLike, connection, deletedLike);
    return deletedLike;
  }
Ejemplo n.º 2
0
  private ArrayList<Post> FilteredFeedPosts() {
    Date daysAgo = new Date(currentTimeMillis() - 1000L * 60L * 60L * 24L * 10);

    Connection<Post> filteredFeed =
        facebookClient.fetchConnection(
            "me/feed", Post.class, Parameter.with("since", daysAgo), Parameter.with("limit", 100));
    out.println("***********beforehomefeed**********************************");

    return new ArrayList<Post>(filteredFeed.getData());
  }