本文整理汇总了Java中com.restfb.Parameter类的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameter类属于com.restfb包,在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchFacebookUser
import com.restfb.Parameter; //导入依赖的package包/类
private AuthUser fetchFacebookUser(String accessToken)
{
//TODO: this takes too long, maybe cache the access token for a configurable time
FacebookClient client = new DefaultFacebookClient(accessToken, Version.VERSION_2_5);
try
{
User user = client.fetchObject("me", User.class, Parameter.with("fields", "name,email"));
if (user != null)
{
AuthUser authUser = new AuthUser();
authUser.setName(user.getName());
authUser.setEmail(user.getEmail());
authUser.setAuthVendor(AuthVendor.FACEBOOK);
authUser.setSession(accessToken);
return authUser;
}
}
catch (FacebookException ex)
{
}
return null;
}
示例2: collectFeed
import com.restfb.Parameter; //导入依赖的package包/类
private Connection<Post> collectFeed(String pagename) {
AccessToken accessToken = new DefaultFacebookClient(Version.VERSION_2_3).obtainAppAccessToken(ConfigurationObject.MY_APP_ID, ConfigurationObject.MY_APP_SECRET);
FacebookClient facebookClient23 = new DefaultFacebookClient(accessToken.getAccessToken(), Version.VERSION_2_3);
//User user = facebookClient23.fetchObject("me", User.class);
Page page = facebookClient23.fetchObject(pagename, Page.class, Parameter.with("fields","name,id, picture, likes"));
return facebookClient23.fetchConnection(page.getId()+"/feed", Post.class, Parameter.with("fields", "comments, full_picture")); //message,picture, likes, from,
}
示例3: send
import com.restfb.Parameter; //导入依赖的package包/类
protected SendResponse send(MessagingType type, MessageRecipient recipient, NotificationTypeEnum notificationType, MessageTag tag,
Parameter... parameters) {
requireNonNull(type, "'type' must not be null");
requireNonNull(recipient, "'recipient' must not be null");
List<Parameter> params = new ArrayList<>();
params.add(Parameter.with(MESSAGING_TYPE_PARAM_NAME, type.toString()));
params.add(Parameter.with(RECIPIENT_PARAM_NAME, recipient));
if (notificationType != null) {
params.add(Parameter.with(NOTIFICATION_TYPE_PARAM_NAME, notificationType.name()));
}
if (tag != null) {
params.add(Parameter.with(TAG_PARAM_NAME, tag.getTag()));
}
params.addAll(Arrays.asList(parameters));
return send(params.toArray(new Parameter[params.size()]));
}
示例4: setGetStartedButton
import com.restfb.Parameter; //导入依赖的package包/类
@Override
public void setGetStartedButton(CallToAction callToAction) throws FacebookException {
requireNonNull(callToAction, "'callToAction' must not be null");
List<CallToAction> callToActions = Arrays.asList(callToAction);
facebookClient.publish(THREAD_SETTINGS_PATH, SendResponse.class,
Parameter.with(SETTING_TYPE_PARAM_NAME, SettingTypeEnum.call_to_actions),
Parameter.with(THREAD_STATE_PARAM_NAME, ThreadStateEnum.new_thread),
Parameter.with(CALL_TO_ACTIONS_PARAM_NAME, callToActions));
}
示例5: testGetUserProfile
import com.restfb.Parameter; //导入依赖的package包/类
@Test
public void testGetUserProfile() {
String userId = "user id";
User user = new User();
user.setFirstName("first name");
user.setLastName("last name");
ProfilePictureSource picture = new ProfilePictureSource();
picture.setUrl("url");
user.setPicture(picture);
user.setLocale("locale");
user.setTimezone(1.00);
user.setGender("gender");
when(facebookClient.fetchObject(userId, User.class, Parameter.with(USER_FIELDS_PARAM_NAME, USER_FIELDS_DEFAULT_VALUE)))
.thenReturn(user);
assertThat(messenger.getUserProfile(userId), is(user));
}
示例6: publish
import com.restfb.Parameter; //导入依赖的package包/类
protected void publish(final SendMessage sendMessage, final Message message, final IdMessageRecipient recipient) {
LOG.info("sending message to {}", recipient);
if (recipient == null) {
LOG.warn("recipient is {}", recipient);
} else {
final Parameter recipientParam = Parameter.with("recipient", recipient);
final Parameter messageParam = Parameter.with("message", message);
final FacebookClient facebookClient = provideFacebookClient(sendMessage);
facebookClient.publish("me/messages", SendResponse.class, recipientParam, messageParam);
}
}
示例7: publishMessage
import com.restfb.Parameter; //导入依赖的package包/类
String publishMessage() {
out.println("* Feed publishing *");
FacebookType publishMessageResponse =
facebookClient.publish("me/feed", FacebookType.class, Parameter.with("message", "RestFB test"));
out.println("Published message ID: " + publishMessageResponse.getId());
return publishMessageResponse.getId();
}
示例8: publishEvent
import com.restfb.Parameter; //导入依赖的package包/类
String publishEvent() {
out.println("* Event publishing *");
Date tomorrow = new Date(currentTimeMillis() + 1000L * 60L * 60L * 24L);
Date twoDaysFromNow = new Date(currentTimeMillis() + 1000L * 60L * 60L * 48L);
FacebookType publishEventResponse =
facebookClient.publish("me/events", FacebookType.class, Parameter.with("name", "Party"),
Parameter.with("start_time", tomorrow), Parameter.with("end_time", twoDaysFromNow));
out.println("Published event ID: " + publishEventResponse.getId());
return publishEventResponse.getId();
}
示例9: publishPhoto
import com.restfb.Parameter; //导入依赖的package包/类
String publishPhoto() {
out.println("* Binary file publishing *");
FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,
BinaryAttachment.with("cat.png", getClass().getResourceAsStream("/cat.png")),
Parameter.with("message", "Test cat"));
out.println("Published photo ID: " + publishPhotoResponse.getId());
return publishPhotoResponse.getId();
}
示例10: generateSNSConfig
import com.restfb.Parameter; //导入依赖的package包/类
@Override
public UserSNSConfigVO generateSNSConfig(String providerUserId, JSONObject additionalConfig) {
try {
UserSNSConfigVO userSNSConfigVO = new UserSNSConfigVO();
userSNSConfigVO.setSnsName(getSNSServiceName());
userSNSConfigVO.setSocialNetworkVO(facebookConfig);
userSNSConfigVO.setNotify(false);
FacebookClient client = new DefaultFacebookClient(additionalConfig.getString(FacebookUtil.FB_ACCESS_TOKEN_KEY), FB_API_VERSION);
User fbUser = client.fetchObject("me", User.class, Parameter.with("fields", "name,email,gender,locale,timezone"));
userSNSConfigVO.setSnsuid(fbUser.getId());
additionalConfig.put("name", fbUser.getName());
additionalConfig.put("email", fbUser.getEmail());
additionalConfig.put("gender", fbUser.getGender());
additionalConfig.put("locale", fbUser.getLocale());
additionalConfig.put("timezone", fbUser.getTimezone());
FacebookClient.AccessToken extendedAccessToken = client.obtainExtendedAccessToken(clientKey, clientSecret);
additionalConfig.put(FacebookUtil.FB_ACCESS_TOKEN_KEY, extendedAccessToken.getAccessToken());
additionalConfig.put(FacebookUtil.EXPIRES_KEY, extendedAccessToken.getExpires().getTime());
userSNSConfigVO.setAdditionalConfig(additionalConfig);
userSNSConfigVO.setUpdatedDate(new Date());
return userSNSConfigVO;
} catch (JSONException ex) {
myLog.error("Error parsing JSON object.", ex);
return null;
}
}
示例11: testRemoveMultipleDomainWhitelisting
import com.restfb.Parameter; //导入依赖的package包/类
@Test
public void testRemoveMultipleDomainWhitelisting() {
List<String> urls = Arrays.asList("domain url 1", "domain url 2");
messenger.removeDomainWhitelisting(urls);
verify(facebookClient).publish(THREAD_SETTINGS_PATH, SendResponse.class,
Parameter.with(SETTING_TYPE_PARAM_NAME, SettingTypeEnum.domain_whitelisting),
Parameter.with(WHITELISTED_DOMAINS_PARAM_NAME, urls),
Parameter.with(DOMAIN_ACTION_TYPE_PARAM_NAME, DomainActionTypeEnum.remove));
}
示例12: setGreeting
import com.restfb.Parameter; //导入依赖的package包/类
@Override
public void setGreeting(Greeting greeting) throws FacebookException {
requireNonNull(greeting, "'greeting' must not be null");
facebookClient.publish(THREAD_SETTINGS_PATH, SendResponse.class,
Parameter.with(SETTING_TYPE_PARAM_NAME, SettingTypeEnum.greeting),
Parameter.with(GREETING_PARAM_NAME, greeting));
}
示例13: setPersistentMenu
import com.restfb.Parameter; //导入依赖的package包/类
@Override
public void setPersistentMenu(List<CallToAction> callToActions) throws FacebookException {
requireNonNull(callToActions, "'callToActions' must not be null");
facebookClient.publish(THREAD_SETTINGS_PATH, SendResponse.class,
Parameter.with(SETTING_TYPE_PARAM_NAME, SettingTypeEnum.call_to_actions),
Parameter.with(THREAD_STATE_PARAM_NAME, ThreadStateEnum.existing_thread),
Parameter.with(CALL_TO_ACTIONS_PARAM_NAME, callToActions));
}
示例14: setAccountLinkingUrl
import com.restfb.Parameter; //导入依赖的package包/类
@Override
public void setAccountLinkingUrl(String url) throws FacebookException {
requireNonNull(url, "'url' must not be null");
facebookClient.publish(THREAD_SETTINGS_PATH, SendResponse.class,
Parameter.with(SETTING_TYPE_PARAM_NAME, SettingTypeEnum.account_linking),
Parameter.with(ACCOUNT_LINKING_URL_PARAM_NAME, url));
}
示例15: testRemovePersistentMenu
import com.restfb.Parameter; //导入依赖的package包/类
@Test
public void testRemovePersistentMenu() {
messenger.removePersistentMenu();
verify(facebookClient).deleteObject(THREAD_SETTINGS_PATH,
Parameter.with(SETTING_TYPE_PARAM_NAME, SettingTypeEnum.call_to_actions),
Parameter.with(THREAD_STATE_PARAM_NAME, ThreadStateEnum.existing_thread));
}