Social Graph

Define relationships between users and use them to personalize their experience

Social Graph is an API-first service that enables products to define and explore the social connections between their users and then use those relationships to personalize features. As a product developer using the Social Graph service, you will be able to:

  • Create and query connections between your users
  • Define your own relationship types like followers, friends, classmates, or anything else
  • Discover and analyze connections in your network of users
  • Integrate with your existing features and user data

Working with the Social Graph Service

All social graph functions are available via a single client interface per platform.

socialGraphClient = (application as LiveLikeApplication).sdk.socialGraphClient()
let sdk: EngagementSDK
sdk.socialGraphClient
import LiveLike from "@livelike/engagementsdk";

All relations between profiles must fall into a predefined relationship type. These relationship types can be Queried via the client interface.

socialGraphClient.getProfileRelationshipTypes(
    LiveLikePagination.FIRST,
    object : LiveLikeCallback<List<ProfileRelationshipType>>(){
        override fun onResponse(result: List<ProfileRelationshipType>?, error: String?) {
            ...
        }
    }
)
let sdk: EngagementSDK
sdk.socialGraphClient.getProfileRelationshipTypes(
	page: .first,
  options: nil
) { result in
   
   switch result {
   case .failure(let error):
   	// handle error             
   case .success(let relationshipTypes):
   	// handle success        
   }
}
LiveLike.getProfileRelationshipTypes().then(({results}) => console.log(results))

Querying relationships

Using the client you can query relationships by any combination of the three parameters to profile, relationship type and from profile

This is an example to find who is following me

socialGraphClient.getProfileRelationships(
    GetProfileRelationshipsRequestParams(
        relationshipTypeKey = "follow",
        toProfileId = "my profile id",
    ),
    LiveLikePagination.FIRST,
    object : LiveLikeCallback<List<ProfileRelationship>>() {
        override fun onResponse(
            result: List<ProfileRelationship>?,
            error: String?
        ) {
            ...
        }
    }
)
let sdk: EngagementSDK
let requestOptions = GetProfileRelationshipsOptions(
  relationshipTypeKey: "follow",
  fromProfileID: nil,
  toProfileID: "my profile ID"
)

sdk.socialGraphClient.getProfileRelationships(
	page: .first,
  options: requestOptions
) { result in
   
   switch result {
   case .failure(let error):
   	// handle error             
   case .success(let relationshipTypes):
   	// handle success        
   }
}
LiveLike.getProfileRelationships({
   relationshipTypeKey: "follow",
   toProfileId: "<Profile ID>",
 }).then(({results}) => console.log(results))

This example is who am I following

socialGraphClient.getProfileRelationships(
    GetProfileRelationshipsRequestParams(
        fromProfileId = "my profile id",
        relationshipTypeKey = "follow",
    ),
    LiveLikePagination.FIRST,
    object : LiveLikeCallback<List<ProfileRelationship>>() {
        override fun onResponse(
            result: List<ProfileRelationship>?,
            error: String?
        ) {
            ...
        }
    }
)
let sdk: EngagementSDK
let requestOptions = GetProfileRelationshipsOptions(
  relationshipTypeKey: "follow",
  fromProfileID: "my profile ID",
  toProfileID: nil
)

sdk.socialGraphClient.getProfileRelationships(
	page: .first,
  options: requestOptions
) { result in
   
   switch result {
   case .failure(let error):
   	// handle error             
   case .success(let relationshipTypes):
   	// handle success        
   }
}
LiveLike.getProfileRelationships({
   relationshipTypeKey: "follow",
   fromProfileId: "<Profile ID>",
 }).then(({results}) => console.log(results))

Managing relationships

Creating relationships is done one at a time via the client interface

socialGraphClient.createProfileRelationship(
    CreateProfileRelationshipRequestParams(
        fromProfileId = "my profile id",
        relationshipTypeKey = "follow",
        toProfileId = "profile id i'm following",
    ),
    object : LiveLikeCallback<ProfileRelationship> (){
        override fun onResponse(result: ProfileRelationship?, error: String?) {
            ...
        }
    }
)
let sdk: EngagementSDK
let requestOptions = CreateProfileRelationshipOptions(
  fromProfileID: "source profile ID",
  toProfileID: "target profile ID",
  relationshipTypeKey: "follow"
)

sdk.socialGraphClient.createProfileRelationship(
  options: requestOptions
) { result in
   
   switch result {
   case .failure(let error):
   	// handle error             
   case .success(let relationshipTypes):
   	// handle success        
   }
}
LiveLike.createProfileRelationship({
   relationshipTypeKey: "follow",
   toProfileId: "<Profile ID>",
   fromProfileId: "<Profile ID>",
 }).then((profileRelationship) => console.log(profileRelationship))

Deleting relationships is similarly achieved via the client interface

socialGraphClient.deleteProfileRelationship(
    DeleteProfileRelationshipsRequestParams( "id of relationship" ),
    object : LiveLikeCallback<LiveLikeEmptyResponse> (){
        override fun onResponse(result: LiveLikeEmptyResponse?, error: String?) {
            ...
        }
    }
)
let sdk: EngagementSDK
let requestOptions = DeleteProfileRelationshipOptions(
  profileRelationshipID: "profile relationship ID to delete"
)

sdk.socialGraphClient.deleteProfileRelationship(
  options: requestOptions
) { result in
   
   switch result {
   case .failure(let error):
   	// handle error             
   case .success(let relationshipTypes):
   	// handle success        
   }
}
LiveLike.deleteProfileRelationship({ relationshipId: "<Profile Relationship ID>" })