org.springframework.social.connect.Connection.getProfileUrl()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.springframework.social.connect.Connection.getProfileUrl()方法的一些代码示例,展示了Connection.getProfileUrl()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.getProfileUrl()方法的具体详情如下:
包路径:org.springframework.social.connect.Connection
类名称:Connection
方法名:getProfileUrl

Connection.getProfileUrl介绍

[英]The public URL of the connected user's profile at the provider's site. A client application may use this value along with the displayName to generate a link to the user's profile on the provider's system. May be null if this information is not public or not provided. The value of this property may change if the user updates his or her profile.
[中]提供商站点上已连接用户配置文件的公共URL。客户端应用程序可以将此值与displayName一起使用,以生成指向提供商系统上用户配置文件的链接。如果此信息未公开或未提供,则可能为空。如果用户更新其配置文件,此属性的值可能会更改。

代码示例

代码示例来源:origin: io.loli.social/custom-social-core-extension

private void assertFacebookConnection(Connection<TestFacebookApi> facebook) {
  assertEquals(new ConnectionKey("facebook", "9"), facebook.getKey());
  assertEquals(null, facebook.getDisplayName());
  assertEquals(null, facebook.getProfileUrl());
  assertEquals(null, facebook.getImageUrl());
  TestFacebookApi facebookApi = facebook.getApi();
  assertEquals("234567890", facebookApi.getAccessToken());
  facebook.sync();
  assertEquals("Keith Donald", facebook.getDisplayName());
  assertEquals("http://facebook.com/keith.donald",
      facebook.getProfileUrl());
  assertEquals("http://facebook.com/keith.donald/picture",
      facebook.getImageUrl());
}

代码示例来源:origin: io.loli.social/custom-social-core-extension

private void assertTwitterConnection(Connection<TestTwitterApi> twitter) {
  assertEquals(new ConnectionKey("twitter", "1"), twitter.getKey());
  assertEquals("@kdonald", twitter.getDisplayName());
  assertEquals("http://twitter.com/kdonald", twitter.getProfileUrl());
  assertEquals("http://twitter.com/kdonald/picture",
      twitter.getImageUrl());
  TestTwitterApi twitterApi = twitter.getApi();
  assertEquals("123456789", twitterApi.getAccessToken());
  assertEquals("987654321", twitterApi.getSecret());
  twitter.sync();
  assertEquals("http://twitter.com/kdonald/a_new_picture",
      twitter.getImageUrl());
}

代码示例来源:origin: com.jtbdevelopment.core-games/games-web

@Override
 public String execute(final Connection<?> connection) {
  try {
   Player player = playerRepository.findBySourceAndSourceId(connection.getKey().getProviderId(),
     connection.getKey().getProviderUserId());
   if (player != null) {
    return player.getIdAsString();
   } else {
    P p = playerFactory.newPlayer();
    p.setDisabled(false);
    p.setDisplayName(connection.fetchUserProfile().getName());
    p.setSource(connection.getKey().getProviderId());
    p.setSourceId(connection.getKey().getProviderUserId());
    p.setProfileUrl(connection.getProfileUrl());
    p.setImageUrl(connection.getImageUrl());
    p = playerRepository.save(p);
    return (p == null ? null : p.getIdAsString());
   }

  } catch (Exception e) {
   logger.warn("Experienced exception in AutoConnectionSignUp", e);
   return null;
  }

 }
}

代码示例来源:origin: io.loli.social/custom-social-core-extension

private void assertNewConnection(Connection<TestFacebookApi> connection) {
  assertEquals("facebook", connection.getKey().getProviderId());
  assertEquals("9", connection.getKey().getProviderUserId());
  assertEquals("Keith Donald", connection.getDisplayName());
  assertEquals("http://facebook.com/keith.donald",
      connection.getProfileUrl());
  assertEquals("http://facebook.com/keith.donald/picture",
      connection.getImageUrl());
  assertTrue(connection.test());
  TestFacebookApi api = connection.getApi();
  assertNotNull(api);
  assertEquals("123456789", api.getAccessToken());
  assertEquals("123456789", connection.createData().getAccessToken());
  assertEquals("987654321", connection.createData().getRefreshToken());
}

相关文章