getAccountInCommunity

/api/v2/communities/{communityId}/accounts/{accountId}

All authorized users can retrieve public account information for any account of a community in eHive. A request to the /api/v2/communities/{communityId}/accounts/{accountId} resource will return an Account JSON object.


Try the getAccountInCommunity 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 Length Required Description
communityId Integer Path 32-bit signed two's complement YES The id for the community you wish filter by.
accountId Integer Path 32-bit signed two's complement YES The id for the account you wish to retrieve.

	

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 getAccountInCommunity() method and assign the return value to an Account domain object as follows:
    Account account = eHiveApi.getAccountInCommunity(1001, 3406);
  3. Access the account information using the Account domain object's getter method.
    String publicProfileName = account.getPublicProfileName();
    System.out.println(publicProfileName);

View the full example:

import com.ehive.api.EHiveApi;
import com.ehive.api.domain.accounts.Account;
import com.ehive.api.domain.objects.Attribute;
import com.ehive.api.domain.objects.Media;
import com.ehive.api.domain.objects.MediaRow;
import com.ehive.api.domain.objects.MediaSet;
import com.ehive.api.domain.objects.Attribute.AttributeIdentifier;
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 GetAccountInCommunity {
	
	private static String clientId = "...462";
	private static String clientSecret = "...98a9";
	private static String trackingId = "...eaca";
	private static String pathToOauthPropertiesFile = "oauth.properties";
	private static Integer accountId = 3406;
	
	private static Integer communityId = 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
		Account account = eHiveApi.getAccountInCommunity(communityId, accountId);
		
		// Print some output using the returned account object
		printAccountInfo(account);
	}
	
	private static void printAccountInfo(Account account) {
		StringBuilder stringBuilder = new StringBuilder();
		
		stringBuilder.append(account.getPublicProfileName() + "\n\n");
		
		stringBuilder.append("About:\n\t");
		stringBuilder.append(account.getAboutCollection());
		stringBuilder.append("\n\n");
		
		stringBuilder.append("Contact Details:\n\t");
		stringBuilder.append("Ph: " + account.getPhoneNumber() + "\n\t");
		stringBuilder.append("Email: " + account.getEmailAddress() + "\n\t");
		stringBuilder.append("Postal Address: " + account.getPostalAddress() + "\n");
		stringBuilder.append("\n\n");
		
		stringBuilder.append("Visitor Info:\n\t");
		stringBuilder.append("Location: " + account.getPhysicalAddress() + "\n\t");
		stringBuilder.append("Opening Hours: " + account.getHoursOfOperation() + "\n");
		stringBuilder.append("\n\n");
		
		stringBuilder.append("Facilities:\n\t");
		
		if (account.getWheelChairAccessFacility()) {
			stringBuilder.append("Wheelchair accessible\n\t");
		}
		
		if (account.getGuidedTourFacility()) {
			stringBuilder.append("Guided Tours\n\t");
		}
		
		if (account.getMembershipClubFacility()) {
			stringBuilder.append("Club Membership\n\t");
		}
		
		if (account.getShopFacility()) {
			stringBuilder.append("Visitors Shop\n\t");
		}
		
		if (account.getParkingFacility()) {
			stringBuilder.append("Parking\n\t");
		}
		
		if (account.getToiletFacility()) {
			stringBuilder.append("Toilets\n\t");
		}
		
		stringBuilder.append(account.getOtherFacility());
		
		stringBuilder.append("\n\n");
		
		for (MediaSet mediaSet : account.getMediaSets()) {
			stringBuilder.append(mediaSet.getIdentifier().toUpperCase() + " URL: \n");
			
			for (MediaRow mediaRow : mediaSet.getMediaRows()) {
				for (Media media : mediaRow.getMedia()) {
					for (Attribute attribute : media.getAttributes()) {
						if (AttributeIdentifier.getIdentifier(attribute.getKey()) == AttributeIdentifier.URL) { 
							stringBuilder.append(attribute.getValue() + "\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(GetAccountInCommunityDemo::$clientId, GetAccountInCommunityDemo::$clientSecret, GetAccountInCommunityDemo::$trackingId);
  3. Invoke the getAccountInCommunity() method and assign the return value to a variable as follows:
    $account = $eHiveApi->getAccountInCommunity(1001, 3406);
  4. Access the information on the account object.
    echo $account->publicProfileName;

View the full example below.


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

class GetAccountInCommunityDemo {
	
	private static $clientId = "...5935";
	private static $clientSecret = "...4c4b";
	private static $trackingId = "...eaca";
	
	private static $accountId = 3406;
	
	private static $communityId = 1001;
	
	public function printAccountInfo() {
		
		// Instantiate the EHiveApi object
		$eHiveApi = new EHiveApi(GetAccountInCommunityDemo::$clientId, GetAccountInCommunityDemo::$clientSecret, GetAccountInCommunityDemo::$trackingId);
		
		// Invoke an API method
		$account = $eHiveApi->getAccountInCommunity(GetAccountInCommunityDemo::$communityId, GetAccountInCommunityDemo::$accountId);
		
		// Print some output using the returned account object
		echo "\n\n" . $account->publicProfileName . "\n\n";
		
		echo "About:\n\t";
		echo $account->aboutCollection;
		echo "\n\n";
		
		echo "Contact Details:\n\t";
		echo "Ph: " . $account->phoneNumber . "\n\t";
		echo "Email: " . $account->emailAddress . "\n\t";
		echo "Postal Address: " . $account->postalAddress . "\n";
		echo "\n\n";
		
		echo "Visitor Info:\n\t";
		echo "Location: " . $account->physicalAddress . "\n\t";
		echo "Opening Hours: " . $account->hoursOfOperation . "\n";
		echo "\n\n";
		
		echo "Facilities:\n\t";
		
		if ($account->wheelChairAccessFacility) {
			echo "Wheelchair accessible\n\t";
		}
		
		if ($account->guidedTourFacility) {
			echo "Guided Tours\n\t";
		}
		
		if ($account->membershipClubFacility) {
			echo "Club Membership\n\t";
		}
		
		if ($account->shopFacility) {
			echo "Visitors Shop\n\t";
		}
		
		if ($account->parkingFacility) {
			echo "Parking\n\t";
		}
		
		if ($account->toiletFacility) {
			echo "Toilets\n\t";
		}
		
		echo $account->otherFacility;
		echo "\n\n";
		
		foreach ($account->mediaSets as $key => $mediaSet) {
			echo strtoupper($mediaSet->identifier) . " URL: \n";
		
			foreach ($mediaSet->mediaRows as $key => $mediaRow) {
				foreach ($mediaRow->media as $key => $media) {
					foreach ($media->attributes as $key => $attribute) {
						if ($attribute->key == 'url') {
							echo "\t" . $attribute->value . "\n";
						}
					}
				}
			}
		}
		echo "\n\n";
	}
}

$getAccountInCommunityDemo = new GetAccountInCommunityDemo();

$getAccountInCommunityDemo->printAccountInfo();