Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Allow passing of additional parameters to OpenGraphOperations publishAct... #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.social.facebook.api;

import org.springframework.util.MultiValueMap;

/**
* Defines operations for working with Facebook OpenGraph actions.
* @author habuma
Expand All @@ -29,5 +31,15 @@ public interface OpenGraphOperations {
* @return the ID of the posted action.
*/
String publishAction(String action, String objectType, String objectUrl);

/**
* Posts an action for an object specified by the given object URL.
* @param action The application specific action to post, without the application's namespace. (eg, "drink")
* @param objectType The application specific object type, without the application's namespace. (eg, "beverage")
* @param objectUrl The URL of the object that is the target of the action.
* @param parameters Optional parameters - see https://developers.facebook.com/docs/opengraph/using-actions/#publish
* @return the ID of the posted action.
*/
String publishAction(String action, String objectType, String objectUrl, MultiValueMap<String, Object> parameters);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ public OpenGraphTemplate(GraphApi graphApi, boolean isAuthorizedForUser) {
}

public String publishAction(String action, String objectType, String objectUrl) {
return publishAction(action, objectType, objectUrl, new LinkedMultiValueMap<String, Object>());
}

public String publishAction(String action, String objectType, String objectUrl, MultiValueMap<String, Object> parameters) {
requireAuthorization();
requireApplicationNamespace();
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
parameters.set(objectType, objectUrl);
return graphApi.publish("me", graphApi.getApplicationNamespace() + ":" + action, parameters);
}
}

private void requireApplicationNamespace() {
String applicationNamespace = graphApi.getApplicationNamespace();
Expand Down