本文整理汇总了Java中com.restfb.types.FacebookType类的典型用法代码示例。如果您正苦于以下问题:Java FacebookType类的具体用法?Java FacebookType怎么用?Java FacebookType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FacebookType类属于com.restfb.types包,在下文中一共展示了FacebookType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishInitialMessage
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
public void publishInitialMessage(User user) {
if (!isServiceEnabled(user)) {
return;
}
FacebookClient client = helper.getFacebookClient(user);
try {
//TODO i18nize
client.publish(OWN_FEED,
FacebookType.class,
Parameter.with(MESSAGE_PARAM, "I am using Welshare!"),
Parameter.with(LINK_PARAM, "http://welshare.com"));
} catch (FacebookException e) {
handleException("Problem sharing initial message to facebook", e, user);
}
}
示例2: post
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
public String post(FacebookPosting posting) {
try {
FacebookClient facebookClient = new DefaultFacebookClient(ACCESS_TOKEN);
FacebookType publishMessageResponse = facebookClient.publish(FACEBOOK_PAGE + "/links", FacebookType.class,
Parameter.with("message", posting.getMessage()),
Parameter.with("link", posting.getLink()),
Parameter.with("og:name", posting.getName()),
Parameter.with("description", posting.getDescription()),
Parameter.with("icon", posting.getPicture()),
Parameter.with("picture", posting.getPicture())
);
String facebookUrl = "http://www.facebook.com/permalink.php?story_fbid=" + publishMessageResponse.getId() + "&id=" + FACEBOOK_PAGE;
log.info("Successfully posted [" + posting.getMessage() + "] to Facebook at [" + facebookUrl + "].");
return facebookUrl;
} catch (RuntimeException e) {
log.warning("Failed to post [" + posting.getMessage() + "] to Facebook.");
log.throwing(getClass().getName(), "post", e);
throw e;
}
}
示例3: publishMessage
import com.restfb.types.FacebookType; //导入依赖的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();
}
示例4: publishEvent
import com.restfb.types.FacebookType; //导入依赖的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();
}
示例5: publishPhoto
import com.restfb.types.FacebookType; //导入依赖的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();
}
示例6: notify
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
protected void notify(Parameters parameters) throws NotificationException {
try {
FacebookClient facebookClient =
createFacebookClient(getConfiguration().getString(KEY_ACCESS_TOKEN));
FacebookType publishResponse;
if (hasMovie()) {
publishResponse = facebookClient.publish("me/videos", FacebookType.class,
BinaryAttachment.with(movie.getFileName().toString(),
Files.readAllBytes(movie),
Files.probeContentType(movie)),
com.restfb.Parameter.with("description", message));
} else if (hasPhoto()) {
publishResponse = facebookClient.publish("me/photos", FacebookType.class,
BinaryAttachment.with(
photo.getFileName().toString(),
Files.readAllBytes(photo),
Files.probeContentType(photo)),
com.restfb.Parameter.with("message", message));
} else {
publishResponse =
facebookClient.publish("me/feed", FacebookType.class,
com.restfb.Parameter.with("message", message));
}
log.debug("Published content has ID {}", publishResponse.getId());
} catch (FacebookException | IOException e) {
throw new NotificationException(e);
}
}
示例7: publishApicture
import com.restfb.types.FacebookType; //导入依赖的package包/类
public void publishApicture(File imageFile) throws IOException {
Path filePath = Paths.get(imageFile.getPath());
byte[] data = Files.readAllBytes(filePath);
String message = photoMsg +", "+ imageFile.getName();
FacebookType publishPhotoResponse = fbClient.publish(
albumID+"/photos",
FacebookType.class,
BinaryAttachment.with(imageFile.getName(), data),
Parameter.with("message", message ) );
System.out.println("Facebook published photo ID: " + publishPhotoResponse.getId());
}
示例8: makeTestPost
import com.restfb.types.FacebookType; //导入依赖的package包/类
public void makeTestPost() throws IOException {
byte[] data = Files.readAllBytes(Paths.get("C:\\Pierre\\selfpi\\doc\\beer.jpg"));
FacebookType publishPhotoResponse = fbClient.publish(
"me/photos",
FacebookType.class,
BinaryAttachment.with("beer.jpg", data),
Parameter.with("message", "Test "+new Date().getTime()) );
System.out.println("Published photo ID: " + publishPhotoResponse.getId());
}
示例9: reply
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
@Async
@SqlTransactional
public void reply(String originalMessageId, Message message) {
if (!isServiceEnabled(message.getAuthor())) {
return;
}
final FacebookClient client = helper.getFacebookClient(message.getAuthor());
final String fbId = getFacebookId(originalMessageId);
try {
String text = message.getText();
// trimming usernames. That's for the cases when the two users are
// both on welshare and facebook, and one replies to the other on
// welshare. This will include a username in the reply, which should
// not be shown on facebook
text = trimUsernames(text);
text = SocialUtils.trimSpecialSymbolElements(text);
final String textParam = text;
FacebookType result = RetryableOperation.create(new Callable<FacebookType>() {
@Override
public FacebookType call() throws Exception {
return client.publish("/" + fbId + "/comments", FacebookType.class,
Parameter.with(MESSAGE_PARAM, textParam));
}
}).retry(retryCount, FacebookException.class);
helper.addToAssociatedMessages(message, result.getId());
} catch (FacebookException e) {
handleException("Problem with replying to a message on facebook", e, message.getAuthor());
}
}
示例10: publishPhoto
import com.restfb.types.FacebookType; //导入依赖的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();
}
示例11: publishSNSMessage
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
public void publishSNSMessage(UserSNSConfigVO userSNSConfigVO, SNSMessageVO snsMessageVO) throws SNSUpdateException {
myLog.debug("[FB] Updating '" + snsMessageVO + "' for " + userSNSConfigVO.getUserVO().getUserid());
try {
JSONObject additionalConfig = userSNSConfigVO.getAdditionalConfig();
FacebookClient client = new DefaultFacebookClient(additionalConfig.getString(FacebookUtil.FB_ACCESS_TOKEN_KEY), FB_API_VERSION);
// Extend access token
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());
this.upsertSNSConfig(userSNSConfigVO.getUserVO(), userSNSConfigVO);
String message = null;
if (snsMessageVO instanceof TemplateBasedSNSMessageVO) {
ContentBasedSNSMessageVO contentBasedSNSMessageVO = ContentBasedSNSMessageVO.fromTemplateBasedSNSMessageVO((TemplateBasedSNSMessageVO) snsMessageVO, arTemplateEngine, ARMessageTemplateField.FACEBOOK_POST);
message = contentBasedSNSMessageVO.getBody();
} else if (snsMessageVO instanceof ContentBasedSNSMessageVO) {
message = ((ContentBasedSNSMessageVO) snsMessageVO).getBody();
}
// Publish message
FacebookType publishMessageResponse =
client.publish("me/feed", FacebookType.class,
Parameter.with("message", message));
// Save log
SNSLogVO snsLogVO = new SNSLogVO();
snsLogVO.setSnsName(FacebookUtil.FACEBOOK_NAME);
snsLogVO.setSnsUid(userSNSConfigVO.getSnsuid());
snsLogVO.setSnsMessageId(publishMessageResponse.getId());
snsLogVO.setUserid(userSNSConfigVO.getUserid());
snsLogVO.setMessageType(snsMessageVO.getMessageType());
snsLogVO.setMessage(message);
snsLogVO.setCreatedAt(new Date());
snsLogDAO.create(snsLogVO);
} catch (JSONException ex) {
myLog.error("Error parsing JSON object.", ex);
}
}
示例12: postMessage
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
public void postMessage(String pStrMessage) {
facebookClient.publish("me/feed", FacebookType.class,
Parameter.with("message", pStrMessage));
}
示例13: getEnclosedEntity
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
public FacebookType getEnclosedEntity() {
return category;
}
示例14: getEnclosedEntity
import com.restfb.types.FacebookType; //导入依赖的package包/类
@Override
public FacebookType getEnclosedEntity() {
return this.user;
}
示例15: StubWrapper
import com.restfb.types.FacebookType; //导入依赖的package包/类
StubWrapper(FacebookType entity){
this.entity = entity;
}