⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 facebookrestclient.java

📁 FACEBOOK上
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
  /**   * Publish a story to the logged-in user's newsfeed.   * @param title the title of the feed story   * @param body the body of the feed story   * @param images (optional) up to four pairs of image URLs and (possibly null) link URLs   * @return whether the story was successfully published; false in case of permission error   * @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishStoryToUser">   *      Developers Wiki: Feed.publishStoryToUser</a>   */  public boolean feed_publishStoryToUser(CharSequence title, CharSequence body,                                         Collection<IFeedImage> images)    throws FacebookException, IOException {    return feed_publishStoryToUser(title, body, images, null);  }  /**   * Publish a story to the logged-in user's newsfeed.   * @param title the title of the feed story   * @param body the body of the feed story   * @param priority   * @return whether the story was successfully published; false in case of permission error   * @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishStoryToUser">   *      Developers Wiki: Feed.publishStoryToUser</a>   */  public boolean feed_publishStoryToUser(CharSequence title, CharSequence body, Integer priority)    throws FacebookException, IOException {    return feed_publishStoryToUser(title, body, null, priority);  }  /**   * Publish a story to the logged-in user's newsfeed.   * @param title the title of the feed story   * @param body the body of the feed story   * @param images (optional) up to four pairs of image URLs and (possibly null) link URLs   * @param priority   * @return whether the story was successfully published; false in case of permission error   * @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishStoryToUser">   *      Developers Wiki: Feed.publishStoryToUser</a>   */  public boolean feed_publishStoryToUser(CharSequence title, CharSequence body,                                         Collection<IFeedImage> images, Integer priority)    throws FacebookException, IOException {    return feedHandler(FacebookMethod.FEED_PUBLISH_STORY_TO_USER, title, body, images, priority);  }  /**   * Publishes a Mini-Feed story describing an action taken by a user, and   * publishes aggregating News Feed stories to the friends of that user.   * Stories are identified as being combinable if they have matching templates and substituted values.   * @param actorId the user into whose mini-feed the story is being published.   * @param titleTemplate markup (up to 60 chars, tags excluded) for the feed story's title   *        section. Must include the token <code>{actor}</code>.   * @return whether the action story was successfully published; false in case   *         of a permission error   * @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishTemplatizedAction">   *      Developers Wiki: Feed.publishTemplatizedAction</a>   * @see <a href="http://developers.facebook.com/tools.php?feed">   *      Developers Resources: Feed Preview Console </a>   */  public boolean feed_publishTemplatizedAction(Integer actorId, CharSequence titleTemplate)    throws FacebookException, IOException {    return feed_publishTemplatizedAction(actorId, titleTemplate, null, null, null, null, null, null);  }  /**   * Publishes a Mini-Feed story describing an action taken by a user, and   * publishes aggregating News Feed stories to the friends of that user.   * Stories are identified as being combinable if they have matching templates and substituted values.   * @param actorId the user into whose mini-feed the story is being published.   * @param titleTemplate markup (up to 60 chars, tags excluded) for the feed story's title   *        section. Must include the token <code>{actor}</code>.   * @param titleData (optional) contains token-substitution mappings for tokens that appear in   *        titleTemplate. Should not contain mappings for the <code>{actor}</code> or   *        <code>{target}</code> tokens. Required if tokens other than <code>{actor}</code>   *        or <code>{target}</code> appear in the titleTemplate.   * @param bodyTemplate (optional) markup to be displayed in the feed story's body section.   *        can include tokens, of the form <code>{token}</code>, to be substituted using   *        bodyData.   * @param bodyData (optional) contains token-substitution mappings for tokens that appear in   *        bodyTemplate. Required if the bodyTemplate contains tokens other than <code>{actor}</code>   *        and <code>{target}</code>.   * @param bodyGeneral (optional) additional body markup that is not aggregated. If multiple instances   *        of this templated story are combined together, the markup in the bodyGeneral of   *        one of their stories may be displayed.   * @param targetIds The user ids of friends of the actor, used for stories about a direct action between   *        the actor and these targets of his/her action. Required if either the titleTemplate or bodyTemplate   *        includes the token <code>{target}</code>.   * @param images (optional) additional body markup that is not aggregated. If multiple instances   *        of this templated story are combined together, the markup in the bodyGeneral of   *        one of their stories may be displayed.   * @return whether the action story was successfully published; false in case   *         of a permission error   * @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishTemplatizedAction">   *      Developers Wiki: Feed.publishTemplatizedAction</a>   * @see <a href="http://developers.facebook.com/tools.php?feed">   *      Developers Resources: Feed Preview Console </a>   */  public boolean feed_publishTemplatizedAction(Integer actorId, CharSequence titleTemplate,                                               Map<String, CharSequence> titleData,                                               CharSequence bodyTemplate,                                               Map<String, CharSequence> bodyData,                                               CharSequence bodyGeneral,                                               Collection<Integer> targetIds,                                               Collection<IFeedImage> images)    throws FacebookException, IOException {    assert null != actorId && actorId > 0 : "Invalid actorId: " + Integer.toString(actorId);    assert null != titleTemplate && !"".equals(titleTemplate);    FacebookMethod method = FacebookMethod.FEED_PUBLISH_TEMPLATIZED_ACTION;    ArrayList<Pair<String, CharSequence>> params =      new ArrayList<Pair<String, CharSequence>>(method.numParams());    params.add(new Pair<String, CharSequence>("actor_id", actorId.toString()));    params.add(new Pair<String, CharSequence>("title_template", titleTemplate));    if (null != titleData && !titleData.isEmpty()) {      JSONObject titleDataJson = new JSONObject();      titleDataJson.putAll(titleData);      params.add(new Pair<String, CharSequence>("title_data", titleDataJson.toString()));    }    if (null != bodyTemplate && !"".equals(bodyTemplate)) {      params.add(new Pair<String, CharSequence>("body_template", bodyTemplate));      if (null != bodyData && !bodyData.isEmpty()) {        JSONObject bodyDataJson = new JSONObject();        bodyDataJson.putAll(bodyData);        params.add(new Pair<String, CharSequence>("body_data", bodyDataJson.toString()));      }    }    if (null != bodyGeneral && !"".equals(bodyGeneral)) {      params.add(new Pair<String, CharSequence>("body_general", bodyGeneral));    }    if (null != targetIds && !targetIds.isEmpty()) {      params.add(new Pair<String, CharSequence>("target_ids", delimit(targetIds)));    }    handleFeedImages(params, images);    return extractBoolean(this.callMethod(method, params));  }  /**   * Retrieves the membership list of a group   * @param groupId the group id   * @return a T containing four membership lists of   * 'members', 'admins', 'officers', and 'not_replied'   */  public T groups_getMembers(Number groupId)    throws FacebookException, IOException {    assert (null != groupId);    return this.callMethod(FacebookMethod.GROUPS_GET_MEMBERS,                           new Pair<String, CharSequence>("gid", groupId.toString()));  }  private static String encode(CharSequence target) {    String result = target.toString();    try {      result = URLEncoder.encode(result, "UTF8");    } catch (UnsupportedEncodingException e) {      System.err.printf("Unsuccessful attempt to encode '%s' into UTF8", result);    }    return result;  }  /**   * Retrieves the membership list of an event   * @param eventId event id   * @return T consisting of four membership lists corresponding to RSVP status, with keys   * 'attending', 'unsure', 'declined', and 'not_replied'   */  public T events_getMembers(Number eventId)    throws FacebookException, IOException {    assert (null != eventId);    return this.callMethod(FacebookMethod.EVENTS_GET_MEMBERS,                           new Pair<String, CharSequence>("eid", eventId.toString()));  }  /**   * Retrieves the friends of the currently logged in user, who are also users   * of the calling application.   * @return array of friends   */  public T friends_getAppUsers()    throws FacebookException, IOException {    return this.callMethod(FacebookMethod.FRIENDS_GET_APP_USERS);  }  /**   * Retrieves the results of a Facebook Query Language query   * @param query : the FQL query statement   * @return varies depending on the FQL query   */  public T fql_query(CharSequence query)    throws FacebookException, IOException {    assert (null != query);    return this.callMethod(FacebookMethod.FQL_QUERY,                           new Pair<String, CharSequence>("query", query));  }  private String generateSignature(List<String> params, boolean requiresSession) {    String secret = (isDesktop() && requiresSession) ? this._sessionSecret : this._secret;    return FacebookSignatureUtil.generateSignature(params, secret);  }  public static void setDebugAll(boolean isDebug) {    FacebookRestClient.DEBUG = isDebug;  }  private static CharSequence delimit(Collection iterable) {    // could add a thread-safe version that uses StringBuffer as well    if (iterable == null || iterable.isEmpty())      return null;    StringBuilder buffer = new StringBuilder();    boolean notFirst = false;    for (Object item : iterable) {      if (notFirst)        buffer.append(",");      else        notFirst = true;      buffer.append(item.toString());    }    return buffer;  }  /**   * Call the specified method, with the given parameters, and return a DOM tree with the results.   *   * @param method the fieldName of the method   * @param paramPairs a list of arguments to the method   * @throws Exception with a description of any errors given to us by the server.   */  protected T callMethod(IFacebookMethod method, Pair<String, CharSequence>... paramPairs)    throws FacebookException, IOException {    return callMethod(method, Arrays.asList(paramPairs));  }  /**   * Used to retrieve photo objects using the search parameters (one or more of the   * parameters must be provided).   *   * @param albumId retrieve from photos from this album (optional)   * @param photoIds retrieve from this list of photos (optional)   * @return an T of photo objects.   * @see #photos_get(Integer, Long, Collection)   * @see <a href="http://wiki.developers.facebook.com/index.php/Photos.get">   *      Developers Wiki: Photos.get</a>   */  public T photos_get(Long albumId, Collection<Long> photoIds)    throws FacebookException, IOException {    return photos_get( /*subjId*/null, albumId, photoIds);  }  /**   * Used to retrieve photo objects using the search parameters (one or more of the   * parameters must be provided).   *   * @param photoIds retrieve from this list of photos (optional)   * @return an T of photo objects.   * @see #photos_get(Integer, Long, Collection)   * @see <a href="http://wiki.developers.facebook.com/index.php/Photos.get">   *      Developers Wiki: Photos.get</a>   */  public T photos_get(Collection<Long> photoIds)    throws FacebookException, IOException {    return photos_get( /*subjId*/null, /*albumId*/null, photoIds);  }  /**   * Used to retrieve photo objects using the search parameters (one or more of the   * parameters must be provided).   *   * @param subjId retrieve from photos associated with this user (optional).   * @param albumId retrieve from photos from this album (optional)   * @return an T of photo objects.   * @see #photos_get(Integer, Long, Collection)   * @see <a href="http://wiki.developers.facebook.com/index.php/Photos.get">   *      Developers Wiki: Photos.get</a>   */  public T photos_get(Integer subjId, Long albumId)    throws FacebookException, IOException {    return photos_get(subjId, albumId, /*photoIds*/null) ;  }  /**   * Used to retrieve photo objects using the search parameters (one or more of the   * parameters must be provided).   *   * @param subjId retrieve from photos associated with this user (optional).   * @param photoIds retrieve from this list of photos (optional)   * @return an T of photo objects.   * @see #photos_get(Integer, Long, Collection)   * @see <a href="http://wiki.developers.facebook.com/index.php/Photos.get">   *      Developers Wiki: Photos.get</a>   */  public T photos_get(Integer subjId, Collection<Long> photoIds)    throws FacebookException, IOException {    return photos_get(subjId, /*albumId*/null, photoIds);  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -