Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_wp_footnotes_kses_init' not found or invalid function name in /home/clients/d53f41ae2001453fbced93bf985d42c7/web/wp-includes/class-wp-hook.php on line 307

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_wp_footnotes_kses_init' not found or invalid function name in /home/clients/d53f41ae2001453fbced93bf985d42c7/web/wp-includes/class-wp-hook.php on line 307
Betaseries API – Yvonnou Théo }
Yvonnou Theo

Design and development engineer

Infotel

Java developer

Yvonnou Theo

Design and development engineer

Infotel

Java developer

Blog Post

Betaseries API

8 October 2022 API, English
Betaseries API

How to access the statistics of a betaseries account and display them on your site using the BetaSeries api.

Retrieve accesses

To access the Betaserie API you will need :

  1. Get the api key -> make the request on the BetaSeries website.
  2. Get your account ID -> use the console here and make the following request:

(To get your password in md5 you can use this site).

Using Curl to perform the query

To make the request to the API I use this method to retrieve the data through the url provided in parameter.

// Fonction qui fait la requête à l'api
function CallAPI($method, $url, $data = false) {     
	$curl = curl_init();      
	switch ($method)     {         
		case "POST":             
			curl_setopt($curl, CURLOPT_POST, 1);              
			if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data);             
			break;         
		case "PUT":             
			curl_setopt($curl, CURLOPT_PUT, 1);             
			break;        
		default:             
			if ($data) $url = sprintf("%s?%s", $url, http_build_query($data));     
	}      
	curl_setopt($curl, CURLOPT_URL, $url);     
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);      
	$result = curl_exec($curl);      
	curl_close($curl);     
	return json_decode($result, true); 
}

Retrieval of member data

To retrieve the member’s data we use the following url:

https://api.betaseries.com/members/infos?key=Your api key&id=Account ID&summary=true 

Here are the elements that can be accessed:

member: member_infos*
member_infos:
  - id: integer
  - fb_id: integer
  - login: string
  - xp: integer
  - cached: integer
  - avatar: url
  - profile_banner: url
  - in_account: boolean
  - subscription: integer
  - stats:
     - friends: integer
     - shows: integer
     - seasons: integer
     - episodes: integer
     - comments: integer
     - progress: integer
     - episodes_to_watch: integer
     - time_on_tv: integer
     - time_to_spend: integer
     - movies: integer
     - badges: integer
     - member_since_days: integer
     - friends_of_friends: integer
     - episodes_per_month: integer
     - favorite_day: string
     - five_stars_percent: integer
     - four-five_stars_total: integer
     - streak_days: integer
     - favorite_genre: string
     - written_words: integer
     - without_days: integer
     - shows_finished: integer
     - shows_current: integer
     - shows_to_watch: integer
     - shows_abandoned: integer
     - movies_to_watch: integer
     - time_on_movies: integer
  - options:
    - downloaded: boolean
    - notation: boolean
    - timelag: boolean
    - global: boolean
    - specials: boolean
    - episodes_tri: integer
    - friendship: string

An example with the number of episodes seen:

function getNbEpisodeVu(){
        // Recuperation des donnees
	$result = CallAPI("", "https://api.betaseries.com/members/infos?key=Your api key&id=Account ID&summary=true");  
	return $result['member']['stats']['episodes'];    
}

And another example with the time spent watching TV:

function getAllTimeLostInFrontOfTvEN(){
    $result = CallAPI("", "https://api.betaseries.com/members/infos?key=Your api key&id=Account ID&summary=true"); 
    $sec = $result['member']['stats']['time_on_tv'] * 60;

	$date1 = new DateTime("@0"); //starting seconds
	$date2 = new DateTime("@$sec"); // ending seconds
	$interval =  date_diff($date1, $date2); //the time difference
	
	$monthleft = $interval->format('%m');
	$daysleft = $interval->format('%d');
	$hoursleft = $interval->format('%h');
	$minleft = $interval->format('%i');

	return $monthleft 
		. ($monthleft > 1 ? ' months' : ' month') 
		. ', ' 
		. $daysleft 
		. ($daysleft > 1 ? ' days' : ' day') 
		. ', ' 
		. $hoursleft 
		. ($hoursleft > 1 ? ' hours and ' : ' hour and ') 
		. $minleft
		. ($minleft > 1 ? ' minutes in front of TV.' : ' minute in front of TV.');

Retrieving data from member news

To get the member’s news we use the following url:

https://api.betaseries.com/timeline/member?key=Your API key&id=Account ID&summary=true 

Here are the elements that can be accessed:

events: event*
event:
  - id: integer
  - type: string
  - ref: string # Vouée à disparaître
  - ref_id: integer
  - user: string
  - user_id: integer
  - html: html
  - date: datetime
  - comments: integer
  - first_comments: comment*

An example with the display of the last episode seen:

function getLastEventEN(){
	$result = CallAPI("", "https://api.betaseries.com/timeline/member?key=Your api key&id=Account ID&summary=true "); 
    
	for ($i=0; $i<10; $i++) {
		if ($result['events'][strval($i)]['type'] == "markas") {
			$res = str_replace("vient de regarder ", "Last episode seen :", $result['events'][strval($i)]['html']);
			return $res;
		}
	} 
}

In this method I retrieve the first event of type markas in the last 10 events of the member. The markas type corresponds to an episode marked as seen.

Display

Here is an example of how this data is displayed: