getTagCloudInCommunity

/api/v2/communities/{communityId}/objectrecords/tagcloud

All authorized users can retrieve tag cloud information from a community in eHive. A request to the /api/v2/communities/{communityId}/objectrecords/tagcloud resource will return an TagCloud JSON object.


Try the getTagCloudInCommunity Method

You can enter real values into the form below and test them against our live API. The response you see is a genuine JSON response from the API.

Name Data Type Parameter Type Value Required Description
communityId Integer Path 32-bit signed two's complement YES The id for the community you wish filter by.
limit Integer Query 32-bit signed two's complement NO The limit query parameters allows you to limit the number of search results per request.

	

Code Examples

Included below are some code snippets from our code samples projects. The examples show the main elements needed to use our API client libraries.

Java

Prerequisites

  1. Download the Java API client library.
  2. Create a new Java class file.
  3. Add the Java API client library JAR to your classpath.
  4. Create a blank file that is accessible from wherever you are running this example. The file is used to store your API authentication token, so it must be readable and writable. You can name the file anything you like as long as it is valid in Java.

Start Coding

  1. Instantiate an EHiveApi object. The EHiveApi object contains all of the methods available in the API. The API requires authentication credentials so you will need to configure your EHiveApi object with valid credentials. There are a number of ways to instantiate the EHiveApi object but for this example you will simply pass all of the parameters you need into the EHiveApi object's constructor:
    private static String clientId = "...462";
    private static String clientSecret = "...98a9";
    private static String trackingId = "...eaca";
    private static String pathToOauthPropertiesFile = "oauth.properties";
    ...
    EHiveApi eHiveApi = new EHiveApi(clientId, clientSecret, trackingId, pathToOauthPropertiesFile);
  2. Invoke the getTagCloudInCommunity() method and assign the return value to an TagCloud domain object as follows:
    TagCloud tagCloud = eHiveApi.getTagCloudInCommunity(1001, 50);
  3. Access the TagCloudTag information using the TagCloudTag domain object's getter method.
    String tag = tagCloudTag.getCleanTagName();
    System.out.println(tag);

View the full example below.

import com.ehive.api.EHiveApi;
import com.ehive.api.domain.tags.TagCloud;
import com.ehive.api.domain.tags.TagCloudTag;
import com.ehive.api.exceptions.EHiveApiException;
import com.ehive.api.exceptions.EHiveFatalServerException;
import com.ehive.api.exceptions.EHiveForbiddenException;
import com.ehive.api.exceptions.EHiveNotFoundException;
import com.ehive.api.exceptions.EHiveUnauthorizedException;

public class GetTagCloudInCommunity {
	
	private static String clientId = "...462";
	private static String clientSecret = "...98a9";
	private static String trackingId = "...eaca";
	private static String pathToOauthPropertiesFile = "oauth.properties";
	
	private static Integer limit = 50;
	private static Integer community_id = 1001;
	
	public static void main(String[] args) throws EHiveApiException, EHiveFatalServerException, EHiveNotFoundException, EHiveUnauthorizedException, EHiveForbiddenException {
		
		// Instantiate the EHiveApi object
		EHiveApi eHiveApi = new EHiveApi(clientId, clientSecret, trackingId, pathToOauthPropertiesFile);
		
		// Invoke an API method
		TagCloud tagCloud = eHiveApi.getTagCloudInCommunity(community_id, limit);
		
		// Print some output using the returned object records tag cloud
		printObjectRecordInfo(tagCloud);
		
	}
	
	private static void printObjectRecordInfo(TagCloud tagCloud) {
		StringBuilder stringBuilder = new StringBuilder();
		
		stringBuilder.append("Total number of tags found: " + tagCloud.getTagCloudTags().size() + "\n\n");
		stringBuilder.append("----------------------------------------------------------------------------\n\n");
		
		for (TagCloudTag tagCloudTag : tagCloud.getTagCloudTags()) {
			stringBuilder.append("Tag: " + tagCloudTag.getCleanTagName() + "\n");

		}
		System.out.println(stringBuilder.toString());
	}
}
		


PHP

Prerequisites

  1. Download the PHP API client library.
  2. Create a new php script file.
  3. Add EHiveApi.php from the PHP API client library to your include path.
  4. Locate the oauth.tok file in the transport/oauth directory of the PHP API client library and ensure that it has both read and write permission enabled.

Start Coding

  1. Instantiate an EHiveApi object. The EHiveApi class contains all of the functions available to you in the API.
  2. Configure your EHiveApi object with valid authentication credentials. There are a number of ways to instantiate the EHiveApi object but for this example you will simply pass all of the parameter you need into the EHiveApi object's constructor:
    private static $clientId = "...5935";
    private static $clientSecret = "...4c4b";
    private static $trackingId = "...eaca";
    
    ...
    $eHiveApi = new EHiveApi(
    				GetTagCloudInAccountDemo::$clientId, 
    				GetTagCloudInAccountDemo::$clientSecret, 
    				GetTagCloudInAccountDemo::$trackingId);
  3. Invoke the getTagCloudInCommunity() method and assign the return value to a variable as follows:
    $tagCloud = $eHiveApi->getTagCloudInCommunity(1001, 50);
  4. Access the information on the ObjectRecord object.
    echo $objectRecordTag->cleanTagName;

View the full example below.


require_once '../../lib/ehive_api_client-php-1.0.0/EHiveApi.php';

class GetTagCloudInCommunityDemo {
	
	private static $clientId = "...5935";
	private static $clientSecret = "...4c4b";
	private static $trackingId = "...eaca";
	

	private static $communityId = 1001;
	private static $limit = 50;

	public function printTagCloudInCommunityInfo() {
		
		// Instantiate the EHiveApi object
		$eHiveApi = new EHiveApi(GetTagCloudInCommunityDemo::$clientId, 
				GetTagCloudInCommunityDemo::$clientSecret, 
				GetTagCloudInCommunityDemo::$trackingId);
		
		// Invoke an API method
		$tagCloudInCommunity = $eHiveApi->getTagCloudInCommunity(
				GetTagCloudInCommunityDemo::$communityId, 
				GetTagCloudInCommunityDemo::$limit);
				
		$totalTagsFound = count($tagCloudInCommunity->tagCloudTags);
		// Print some output using the returned tag cloud object
		echo "\n\nTotal number of tags found: {$totalTagsFound} \n\n";
		echo "----------------------------------------------------------------------------\n\n";
		
		foreach ($tagCloudInCommunity->tagCloudTags as $tagCloudTag) {
			echo "Tag: {$tagCloudTag->cleanTagName}\n";
			
		}
		echo "\n\n";
	}
}

$getObjectRecordsTagCloudInCommunityDemo = new GetTagCloudInCommunityDemo();

$getObjectRecordsTagCloudInCommunityDemo->printTagCloudInCommunityInfo();