Giter Club home page Giter Club logo

tiktok-loginkit-php's Introduction

TikTok Login Kit for PHP

TikTok Login Kit implementation in PHP based on the official documentation.

This is an unofficial SDK for the official Login Kit APIs.

Features

The library has been updated to use the new TikTok v2 API version

Current features include:

  • Log in with TikTok
  • Retrieve Basic User Information
  • Retrieve Advanced User Information
  • Retrieve Videos
  • Paginate Videos
  • Refresh Expired Token

Installation

Install via Composer

composer require gimucco/tiktok-loginkit

Requirements

You need to have your app set up and approved in the TikTok Developer Portal.

If you're upgrading to the v2 TikTok API version, make sure you've added your Redirect URLs and selected the proper scopes.

Code Example for Logging in and retrieving basic info

// Initialize the class. 
// $client_id and $client_secret are provided by TikTok. 
// $redirect_uri must be approved in the TikTok developer portal.
$_TK = new TikTokLoginKit\Connector($client_id, $client_secret, $redirect_uri);
if (TikTokLoginKit\Connector::receivingResponse()) { 
	try {
		$token = $_TK->verifyCode($_GET[TikTokLoginKit\Connector::CODE_PARAM]);
		// Your logic to store the access token
		$user = $_TK->getUser();
		// Your logic to manage the User info
		$videos = $_TK->getUserVideoPages();
		// Your logic to manage the Video info
	} catch (Exception $e) {
		echo "Error: ".$e->getMessage();
		echo '<br /><a href="?">Retry</a>';
	}
} else {
	echo '<a href="'.$_TK->getRedirect().'">Log in with TikTok</a>';
}

Alternative Constructor

If you prefer to use a .ini file to pass the api credentials, you can use the TikTokLoginKit\Connector::fromIni method. The .ini file should have this simple structure

client_id = [your client id]
client_secret = [your client secret]
redirect_uri = [your redirect uri]

And you call the alternative constructor by passing the path to the .ini file

$_TK = TikTokLoginKit\Connector::fromIni(__DIR__.'/env.ini');

Examples

Refer to the examples folder for a quick examples of how to use the login, fetch and paginate videos

tiktok-loginkit-php's People

Contributors

andreaolivato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tiktok-loginkit-php's Issues

Undefined property stdClass::$video_list

Hi this package is really helpful thank you! but im having a few small problems.
A request for video list permissions is not sent, not sure if that is the package because i requested the permission in tiktok dev.
Only avatar and display name.

Screenshot 2022-04-15 at 13 52 23

Login issue with redirect uri

I confugre all details as needed but can't login using your php sdk.
What am i missing??? Please help.

PHP login code:
login tiktok code

Tiktok app details:
tiktok app details

Login Error:
tiktok error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.