当前位置: 首页>>代码示例>>Java>>正文


Java Plus类代码示例

本文整理汇总了Java中com.google.api.services.plus.Plus的典型用法代码示例。如果您正苦于以下问题:Java Plus类的具体用法?Java Plus怎么用?Java Plus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Plus类属于com.google.api.services.plus包,在下文中一共展示了Plus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listPeople

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Get list of people user has shared with this app.
 */
    private Person listPeople() {

        String tokenData = AuthFilter.getToken();

        try {
            // Build credential from stored token data.
            GoogleCredential credential = new GoogleCredential.Builder()
                    .setJsonFactory(JSON_FACTORY)
                    .setTransport(TRANSPORT)
                    .setClientSecrets(CLIENT_ID, CLIENT_SECRET).build()
                    .setFromTokenResponse(JSON_FACTORY.fromString(
                            tokenData, GoogleTokenResponse.class));
            // Create a new authorized API client.
            Plus service = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential)
                    .setApplicationName(APPLICATION_NAME)
                    .build();
            // Get a list of people that this user has shared with this app.
            Person me = service.people().get("me").execute();
//        PeopleFeed people = service.people().list("me", "visible").execute();
            return me;
        } catch (IOException e) {
            throw new RestException(e);
        }
    }
 
开发者ID:turbomanage,项目名称:listmaker,代码行数:28,代码来源:GPlus.java

示例2: addVoteToGooglePlusAppActivity

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Add to the User's Google+ app activity for this app that they voted on
 * the given Photo.
 * @param author User voting.
 * @param photo Photo on which they're voting.
 * @param credential Credential used to authorize the request to Google.
 * @throws MomentWritingException Failed to write app activity to Google.
 */
private void addVoteToGooglePlusAppActivity(User author, Photo photo,
    GoogleCredential credential) throws MomentWritingException {
  ItemScope target = new ItemScope().setUrl(photo.getPhotoContentUrl());
  ItemScope result = new ItemScope().setType("http://schema.org/Review")
      .setName("A vote for a PhotoHunt photo")
      .setUrl(photo.getPhotoContentUrl()).setText("Voted!");
  Moment content = new Moment()
      .setType("http://schemas.google.com/ReviewActivity").setTarget(target)
      .setResult(result);
  Plus plus = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential).build();
  try {
    Insert request = plus.moments().insert(author.googleUserId, "vault",
        content);
    Moment moment = request.execute();
  } catch (IOException e) {
    throw new MomentWritingException(e.getMessage());
  }
}
 
开发者ID:DesenvolvedoresGoogle,项目名称:Allow,代码行数:27,代码来源:VotesServlet.java

示例3: main

import com.google.api.services.plus.Plus; //导入依赖的package包/类
public static void main(String[] args) {
  try {
    httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
    // authorization
    Credential credential = authorize();
    // set up global Plus instance
    plus = new Plus.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName(
        APPLICATION_NAME).build();
    // run commands
    System.out.println("plus application is built");
    
    listActivities();
    getActivity();
    getProfile();
    
    System.out.println("Displayed your activity list,"
 +" some external activity and your profile information");
    // success!
    return;
  } catch (IOException e) {
    System.err.println(e.getMessage());
  } catch (Throwable t) {
    t.printStackTrace();
  }
  System.exit(1);
}
 
开发者ID:sshubhadeep,项目名称:GooglePlusJavaImplementation,代码行数:28,代码来源:GooglePlusConsoleDisplay.java

示例4: getUserInfo

import com.google.api.services.plus.Plus; //导入依赖的package包/类
private User getUserInfo(GoogleTokenResponse accessToken) {
        try {
            // Build credential from stored token data.
            GoogleCredential credential = new GoogleCredential.Builder()
                    .setJsonFactory(JSON_FACTORY)
                    .setTransport(TRANSPORT)
                    .setClientSecrets(CLIENT_ID, CLIENT_SECRET).build()
                    .setFromTokenResponse(JSON_FACTORY.fromString(
                            accessToken.toString(), GoogleTokenResponse.class));
            // Create a new authorized API client.
            Plus service = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential)
                    .setApplicationName(APPLICATION_NAME)
                    .build();
            // Get a list of people that this user has shared with this app.
            Person me = service.people().get("me").execute();

            User newUser = new User();
            GoogleIdToken idToken = accessToken.parseIdToken();
            newUser.setEmailAddress(idToken.getPayload().getEmail());
            newUser.setGoogleId(idToken.getPayload().getSubject());
            newUser.setFirstName(me.getName().getGivenName());
            newUser.setLastName(me.getName().getFamilyName());
            String imageUrl = me.getImage().getUrl();
            newUser.setImgUrl(imageUrl);

            return newUser;

//        PeopleFeed people = service.people().list("me", "visible").execute();
        } catch (IOException e) {
            throw new RestException(e);
        }

    }
 
开发者ID:turbomanage,项目名称:listmaker,代码行数:34,代码来源:GPlus.java

示例5: handleLogin

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * This method should be executed whenever a user logs in It check whether the
 * user exists on TG's datastore and create them, if not. It also checks if
 * the user's email has been changed and update it, in case it was changed.
 *
 * @param user
 *          A Google AppEngine API user
 * @return A response with the user data as it is on TG datastore
 *
 * @throws InternalServerErrorException
 *           in case something goes wrong
 * @throws NotFoundException
 *           in case the information are not founded
 * @throws BadRequestException
 *           in case a request with problem were made.
 * @throws OAuthRequestException
 *           in case of authentication problem
 * @throws IOException
 *           in case of a IO exception
 */
@Override
public TechGalleryUser handleLogin(Integer timezoneOffset, final User user, HttpServletRequest req)
    throws NotFoundException, BadRequestException, InternalServerErrorException, IOException,
    OAuthRequestException {
  authorize(user);
  String userEmail = user.getEmail();
  String header = req.getHeader("Authorization");
  String accesstoken = header.substring(header.indexOf(' ')).trim(); // "Bearer
                                                                     // ".length

  GoogleCredential credential = new GoogleCredential().setAccessToken(accesstoken);
  Plus plus = new Plus.Builder(new NetHttpTransport(), new JacksonFactory(), credential)
      .setApplicationName(i18n.t("Tech Gallery")).build();
  Person person = plus.people().get("me").execute();
  TechGalleryUser tgUser = userDao.findByGoogleId(user.getUserId());
  // Couldn't find by googleID. Try email
  if (tgUser == null) {
    tgUser = userDao.findByEmail(userEmail);
  }
  // Ok, we couldn't find it. Create it.
  if (tgUser == null) {
    tgUser = new TechGalleryUser();
  }
  updateUserInformation(user, person, tgUser);
  tgUser.setTimezoneOffset(timezoneOffset);
  addUser(tgUser);
  log.info("User " + tgUser.getName() + " added/updated");
  return tgUser;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:50,代码来源:UserServiceTGImpl.java

示例6: GooglePlusRetriever

import com.google.api.services.plus.Plus; //导入依赖的package包/类
public GooglePlusRetriever(Credentials credentials) throws Exception {
	super(credentials);
	
	if (credentials.getKey() == null) {
		logger.error("GooglePlus requires authentication.");
		throw new Exception("GooglePlus requires authentication.");
	}
	
	GooglePlusKey = credentials.getKey();
	GoogleCredential credential = new GoogleCredential();
	plusSrv = new Plus.Builder(transport, jsonFactory, credential)
					.setApplicationName("SocialSensor")
					.setHttpRequestInitializer(credential)
					.setPlusRequestInitializer(new PlusRequestInitializer(GooglePlusKey)).build();
}
 
开发者ID:MKLab-ITI,项目名称:simmo-stream-manager,代码行数:16,代码来源:GooglePlusRetriever.java

示例7: GdeAdapter

import com.google.api.services.plus.Plus; //导入依赖的package包/类
public GdeAdapter(Context ctx, GoogleApiClient client) {
    mContext = ctx;
    mInflater = LayoutInflater.from(mContext);
    mGdes = new ArrayList<Gde>();
    mPlusClient = client;
    mConsumedMap = new HashMap<Integer, Object>();

    mClient = new Plus.Builder(mTransport, mJsonFactory, null).setGoogleClientRequestInitializer(new CommonGoogleJsonClientRequestInitializer(ctx.getString(R.string.ip_simple_api_access_key))).setApplicationName("GDG Frisbee").build();
    mPlusPattern = Pattern.compile("http[s]?:\\/\\/plus\\..*google\\.com.*(\\+[a-zA-Z]+|[0-9]{21}).*");
}
 
开发者ID:gdgjodhpur,项目名称:gdgapp,代码行数:11,代码来源:GdeAdapter.java

示例8: search

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Buscar por usuários.
 * 
 * @param name Nome para usar na busca.
 * @param maxResults Máximo de resultados.
 * @return Lista de usuários.
 */
public List<Person> search(String name, long maxResults) throws RuntimeException {
	try {
		Plus.People.Search searchPeople = plus.people().search(name);
		searchPeople.setMaxResults(5L);

		PeopleFeed peopleFeed;
		peopleFeed = searchPeople.execute();
		return peopleFeed.getItems();
	} catch (IOException e) {
		throw new RuntimeException(e);
	}		
}
 
开发者ID:marloncarvalho,项目名称:javamagazine-googleplus,代码行数:20,代码来源:GooglePlus.java

示例9: connect

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Conectar no Google+.
 */
public void connect() {
	try {
		httpTransport = GoogleNetHttpTransport.newTrustedTransport();
		dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);

		Credential credential = authorize();
					
		plus = new Plus.Builder(httpTransport, JSON_FACTORY, credential).
				setApplicationName(APPLICATION_NAME).
				build();			
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:marloncarvalho,项目名称:javamagazine-googleplus,代码行数:18,代码来源:GooglePlus.java

示例10: getActivities

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Obter uma lista contendo as atividades de um usuário no Google+.
 * 
 * @param userID Identificador do usuário que queremos obter as atividades.
 * @param maxResults Quantidade máxima de resultados a serem retornados.
 * @return Lista de atividades do usuário.
 */
public List<Activity> getActivities(String userID, long maxResults) {
	Plus.Activities.List listActivities;
	try {
		listActivities = plus.activities().list(userID, "public");
		listActivities.setMaxResults(maxResults);
		ActivityFeed feed = listActivities.execute();
		return feed.getItems();
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:marloncarvalho,项目名称:javamagazine-googleplus,代码行数:19,代码来源:GooglePlus.java

示例11: addPhotoToGooglePlusHistory

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Creates an app activity in Google indicating that the given User has
 * uploaded the given Photo.
 * @param author Creator of Photo.
 * @param photo Photo itself.
 * @param credential Credential with which to authorize request to Google.
 * @throws MomentWritingException Failed to write app activity.
 */
private void addPhotoToGooglePlusHistory(User author, Photo photo,
    GoogleCredential credential) throws MomentWritingException{
  ItemScope target = new ItemScope().setUrl(photo.getPhotoContentUrl());
  Moment content = new Moment().setType(
      "http://schemas.google.com/AddActivity").setTarget(target);
  Plus plus = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential).build();
  try {
    Insert request = plus.moments().insert(author.googleUserId,
        "vault", content);
    Moment moment = request.execute();
  } catch (IOException e) {
    throw new MomentWritingException(e.getMessage());
  }
}
 
开发者ID:DesenvolvedoresGoogle,项目名称:Allow,代码行数:23,代码来源:PhotosServlet.java

示例12: generateFriends

import com.google.api.services.plus.Plus; //导入依赖的package包/类
/**
 * Query Google for the list of the user's friends that they've shared with
 * our app, and then store those friends for later use.
 * @param user User for which to get friends.
 * @param credential Credential to use to authorize people.list request.
 * @throws IOException Unable to fetch friends because of network error.
 */
private void generateFriends(User user, GoogleCredential credential)
    throws IOException {
  // TODO(silvano): Refactor this method to not have race condition.
  // TODO(silvano): Refactor this method to use task queue.
  // TODO(silvano): Refactor this method to fetch more than first page.

  // Simple but inefficient way of building the friends list
  Plus plus = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential).build();
  Plus.People.List get;
  List<DirectedUserToUserEdge> friends = ofy().load()
      .type(DirectedUserToUserEdge.class)
      .filter("ownerUserId", user.getId()).list();
  ofy().delete().entities(friends);

  get = plus.people().list(user.getGoogleUserId(), "visible");
  PeopleFeed feed = get.execute();
  boolean done = false;
  do {
    for (Person googlePlusPerson : feed.getItems()) {
      User friend = ofy().load().type(User.class).filter(
          "googleUserId", googlePlusPerson.getId()).first().get();
      if (friend != null) {
        DirectedUserToUserEdge friendEdge = new DirectedUserToUserEdge();
        friendEdge.setOwnerUserId(user.getId());
        friendEdge.setFriendUserId(friend.getId());
        ofy().save().entity(friendEdge).now();
      }
    }
    done = true;
  } while (!done);
}
 
开发者ID:DesenvolvedoresGoogle,项目名称:Allow,代码行数:39,代码来源:ConnectServlet.java

示例13: GooglePlusRetriever

import com.google.api.services.plus.Plus; //导入依赖的package包/类
public GooglePlusRetriever(String key,Integer maxResults,Integer maxRequests,Long maxRunningTime) {
	GooglePlusKey = key;
	GoogleCredential credential = new GoogleCredential();
	plusSrv = new Plus.Builder(transport, jsonFactory, credential)
					.setApplicationName("SocialSensor")
					.setHttpRequestInitializer(credential)
					.setPlusRequestInitializer(new PlusRequestInitializer(GooglePlusKey)).build();
	
	this.maxResults = maxResults;
	this.maxRequests = maxRequests;
	this.maxRunningTime = maxRunningTime;
}
 
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:13,代码来源:GooglePlusRetriever.java

示例14: loadInBackground

import com.google.api.services.plus.Plus; //导入依赖的package包/类
@Override
public List<Activity> loadInBackground() {
    mIsLoading = true;

    // Set up the HTTP transport and JSON factory
    HttpTransport httpTransport = new NetHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();

    JsonHttpRequestInitializer initializer = new GoogleKeyInitializer(
            Config.API_KEY);

    // Set up the main Google+ class
    Plus plus = Plus.builder(httpTransport, jsonFactory)
            .setApplicationName(Config.APP_NAME)
            .setJsonHttpRequestInitializer(initializer)
            .build();

    ActivityFeed activities = null;
    try {
        activities = plus.activities().search(mSearchString)
                .setPageToken(mNextPageToken)
                .setMaxResults(MAX_RESULTS_PER_REQUEST)
                .execute();

        mHasError = false;
        mNextPageToken = activities.getNextPageToken();

    } catch (IOException e) {
        e.printStackTrace();
        mHasError = true;
        mNextPageToken = null;
    }

    return (activities != null) ? activities.getItems() : null;
}
 
开发者ID:amardeshbd,项目名称:google-iosched,代码行数:36,代码来源:SocialStreamFragment.java

示例15: loadInBackground

import com.google.api.services.plus.Plus; //导入依赖的package包/类
@Override
public List<Activity> loadInBackground() {
    mIsLoading = true;

    // Set up the HTTP transport and JSON factory
    HttpTransport httpTransport = new NetHttpTransport();
    JsonFactory jsonFactory = new AndroidJsonFactory();

    // Set up the main Google+ class
    Plus plus = new Plus.Builder(httpTransport, jsonFactory, null)
            .setApplicationName(NetUtils.getUserAgent(getContext()))
            .setGoogleClientRequestInitializer(
                    new CommonGoogleClientRequestInitializer(Config.API_KEY))
            .build();

    ActivityFeed activities = null;
    try {
        activities = plus.activities().search(mSearchString)
                .setPageToken(mNextPageToken)
                .setOrderBy("recent")
                .setMaxResults(MAX_RESULTS_PER_REQUEST)
                .setFields(PLUS_RESULT_FIELDS)
                .execute();

        mHasError = false;
        mNextPageToken = activities.getNextPageToken();

    } catch (IOException e) {
        e.printStackTrace();
        mHasError = true;
        mNextPageToken = null;
    }

    return (activities != null) ? activities.getItems() : null;
}
 
开发者ID:TheDeltaProgram,项目名称:iosched2013,代码行数:36,代码来源:SocialStreamFragment.java


注:本文中的com.google.api.services.plus.Plus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。