Skip to content
Andrea Olivato edited this page Jun 3, 2021 · 2 revisions

Welcome to the TikTok-LoginKit-PHP wiki!

Class Connector

The Connector Class includes all the methods to connect and interact with the TikTok Login Kit APIs for Web.

Below is a detailed view of available methods.

getRedirect(array $permissions)

Gets the redirect URI for frontend usage

Generates the Redirect URI. This should be used in the frontend to redirect the user to TikTok to accept the API connection/permissions

@param array $permissions an array containing all the permissions you want to use. Your app must be approved for these permissions @return string the URL to which you need to redirect the user @throws Exception If the requested permissions are wrongly formatter

verifyCode(string $code)

Calls the TikTok APIs to verify an authorisation code and retrieve the access token

First checks to validate the STATE variable. The GET of the state should be the same as the SESSION to prevent CSRF attacks Then calls the TikTok APIs to verify the received authorisation code and exchange it for an Access Token Set the Token and User ID within the class for further use

@param string $code contains the code received via the GET parameter @return string the URL to which you need to redirect the user @throws Exception If the STATE is not valid or if the API return error

getUserInfo()

Calls the TikTok APIs to retrieve all available user information for the logged user @return object the JSON containing the user data @throws Exception If the API returns an error

getUser()

After Calling the TikTok API via the getUserInfo() method, builds and returns the User object of this class for easier handling

@return User the User object @throws Exception If the API returns an error

get(string $url)

Basic HTTP wrapper to perform calls to the TikTok Api

@param string $url The URL to call @return string the response of the call or false

Class User

This class simply manages the structure of the User returned from the APIs into an object

Methods are simply to set and get the values provided by the APIs

Getters

  • getOpenID()
  • getUnionID()
  • getAvatar()
  • getAvatarLarger()
  • getDisplayName()

Class Video

This class simply manages the structure of the Video returned from the APIs into an object

Methods are simply to set and get the values provided by the APIs

Getters

  • getID()
  • getShareURL()
  • getCreateTime()
  • getCoverImageURL()
  • getVideoDescription()
  • getDuration()
  • getHeight()
  • getWidth()