Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Latest Download Submissions Go to All Downloads
Web - My Sports Handbook (g36mitchell) - Submitted by TheSportsDBFan
Submit Date: 08-22-2024, 08:30 PM | Category: Tools and Scripts
PlexSportScanner (Project-Plex) V.0.9.1 - Submitted by TheSportsDBFan
Submit Date: 08-21-2024, 09:54 PM | Category: Plex Plugins
The Sports Database Python- metadata.thesportsdb.python V.1.1.7 - Submitted by TheSportsDBFan
Submit Date: 08-21-2024, 09:16 PM | Category: Kodi Addons
PHP TSDB TV-Guide (Vilhao) - Submitted by TheSportsDBFan
Submit Date: 08-20-2024, 08:53 PM | Category: Tools and Scripts
Texturecache.py V.1.0.0 - Submitted by TheSportsDBFan
Submit Date: 08-16-2024, 10:15 PM | Category: Tools and Scripts
 

Search Forums

(Advanced Search)

Forum Statistics
» Members: 55
» Latest member: pk28ob
» Forum threads: 73
» Forum posts: 77

Full Statistics

Online Users
There are currently 34 online users.
» 0 Member(s) | 33 Guest(s)
Bing

Latest Threads
Player change the team - ...
Forum: Add and maintain content
Last Post: TheSportsDBFan
08-23-2024, 08:55 AM
» Replies: 0
» Views: 131
My Sports Handbook (g36mi...
Forum: Presentation of your projects
Last Post: TheSportsDBFan
08-22-2024, 08:18 PM
» Replies: 0
» Views: 103
DMCA - Digital Millennium...
Forum: Developing - TheSportsDB.com
Last Post: TheSportsDBFan
08-22-2024, 12:35 PM
» Replies: 0
» Views: 122
How to publish your App o...
Forum: Developing - TheSportsDB.com
Last Post: TheSportsDBFan
08-22-2024, 12:32 PM
» Replies: 0
» Views: 107
Leagues of TheSportsdb.co...
Forum: Developing - TheSportsDB.com
Last Post: TheSportsDBFan
08-21-2024, 10:42 PM
» Replies: 0
» Views: 93
Countries of TheSportsdb....
Forum: Developing - TheSportsDB.com
Last Post: TheSportsDBFan
08-21-2024, 10:23 PM
» Replies: 0
» Views: 21,689
PlexSportScanner - SportS...
Forum: Presentation of your projects
Last Post: TheSportsDBFan
08-21-2024, 10:03 PM
» Replies: 0
» Views: 118
Support [Script - Kodi an...
Forum: Support - Other Projects & Tools
Last Post: TheSportsDBFan
08-21-2024, 08:17 PM
» Replies: 0
» Views: 125
Support [Kodi-Addon] Proj...
Forum: Support - Other Projects & Tools
Last Post: TheSportsDBFan
08-21-2024, 08:13 PM
» Replies: 0
» Views: 78
Support: [Kodi-Addon] NFO...
Forum: Support - Other Projects & Tools
Last Post: TheSportsDBFan
08-21-2024, 08:12 PM
» Replies: 0
» Views: 84

 
Exclamation Changes between API V1 and API V2 (migration assistance)
Posted by: TheSportsDBFan - 08-17-2024, 12:04 AM - Forum: Developing - TheSportsDB.com - No Replies

Understanding the new API V2 Features:

Important: If you want to access the API V2 with inserting the API key in the URL =>  thats not longer supported!  You need to check the "CORS" section in this post!

New Features:

Placeholder..



CORS: (Cross-Origin Resource Sharing)

Understanding CORS Preflight Requests: Cross-Origin Resource Sharing (CORS) is a fundamental concept in web development, crucial for enabling secure and controlled access to resources across different domains. At the heart of this mechanism is the CORS preflight request, an essential process that browsers perform to ensure that a client-side web application can safely request resources from a server hosted on a different origin. Understanding this process is key for developers, especially when faced with the common ‘blocked by CORS policy’ error, which indicates a misconfiguration in CORS settings.

Preflight requests use the HTTP OPTIONS method, and they include headers that specify the HTTP method and headers that the actual request will use. When a server receives a preflight request, it responds with the appropriate CORS headers to indicate whether or not the actual request is allowed.

How CORS Preflight Requests are Triggered: CORS preflight requests are triggered automatically by the browser under certain conditions. These conditions include: HTTP methods other than GET, HEAD, or POST. POST requests with content types other than application/x-www-form-urlencoded, multipart/form-data, or text/plain. Requests that set custom headers. For example, a client application making a POST request with JSON data to a server on a different domain will trigger a preflight request. This is because the content type application/json is not one of the simple types, and thus the browser needs to confirm that the server accepts requests of this nature.

   

Wikipedia: https://en.wikipedia.org/wiki/Cross-orig...ce_sharing



Here a Example for Javascript - Jquery: (to get league data)

Code:
//Get League Data
//change 00000000 => to your API KEY!

var fbURLv2="https://www.thesportsdb.com/api/v2/json/all/leagues";
var commentdata = "";
$.ajax({
    url: fbURLv2,
    data: "message="+commentdata,
    dataType: "json",
    type: 'POST',
    beforeSend: function(xhr) {
        xhr.setRequestHeader('X-API-KEY', '00000000');
        xhr.setRequestHeader('Content-Type', 'application/json');
    },
    // If success         
    success: function (resp) {
        console.log(resp);
    },
    // If error
    error: function(e) {
        console.log(e);
    }
});

The most important part is: (It is important to send the authentication before retrieving further data)

Code:
    beforeSend: function(xhr) {
        xhr.setRequestHeader('X-API-KEY', '00000000');
        xhr.setRequestHeader('Content-Type', 'application/json');
    },

You can also set this once for all calls: (Through ajax setup it is automatically added to every call)

Code:
$.ajaxSetup({
    beforeSend: function(xhr) {
        xhr.setRequestHeader('X-API-KEY': '00000000');
    }
});



Here is a Example from PHP:  (Function for GET, POST, PUT & DELETE)

Code:
//Function for API Calls Version 2
function callAPI($method, $url, $data, $api_key)
{
    $curl = curl_init();
    switch (strtoupper($method)) {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    // OPTIONS:
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, [
        "X-API-KEY:" .$api_key,
        "Content-Type: application/json",
    ]);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    // EXECUTE:
    $result = curl_exec($curl);
    if (!$result) {
        die("Connection Failure");
    }
    curl_close($curl);
    return $result;
}

The most important part is: ($api_key = Your API Key)

Code:
    curl_setopt($curl, CURLOPT_HTTPHEADER, [
        "X-API-KEY:" .$api_key,
        "Content-Type: application/json",
    ]);

PHP Example to get all Sports: (with the function)

Code:
//Your Api Key
$api_key = "00000";
$get_data = callAPI('GET', 'https://www.thesportsdb.com/api/v2/json/all/sports', false, $api_key);
$response = json_decode($get_data, true);
try {
    $sports_data = $response;
}
catch(Exception $e) {
    $errors = $response['Message'];
    echo "<p>Error API: " . htmlspecialchars($errors) . "</p>";
    echo "<p>Error PHP: " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "</p>";
    throw new Exception('Failed to fetch data from the API.');
    exit;
}
// Loop through each sport and display the name and image
foreach ($sports_data['all'] as $sport) {
    $sport_name = htmlspecialchars($sport['strSport']); // Get and sanitize the sport name
    $sport_img = $sport['strSportThumb']; // Get the sport image URL from strSportThumb
    // Display the sport image and name
    echo "
        <div class='sport-item'>
            <div class='sport-image' style='background-image: url(" . htmlspecialchars($sport_img) . ");'>
                <div class='sport-name'>" . htmlspecialchars($sport_name) . "</div>
            </div>
        </div>
    ";
}

Download this example with much more Code: PHP TSDB TV-Guide (Vilhao)
Live Example: https://tsdb.club/Presentation_of_projec...isplay.php
Source - Presentation of your projects: [WebProject - API V1+V2] TSDB TV-Guide (Vilhao)
Task - Community: Whoever develops the script further, not only makes it more beautiful, but also allows you to click on events, view the players in detail and find out details about the broadcasters... will receive an API KEY from me for 1 year. However, the project must be made available for everyone to use for at least 1 year and presented on this page. (Begin: DD/MM/YY GMT+2 20.08.2024 23:15:00)



Here is a Example from Python:  (to get league data)

Code:
### Get League Data
### Change 00000000 => to your API KEY!

import requests

url = "https://www.thesportsdb.com/api/v2/json/all/leagues"
api_key = 00000000

headers = {
    "X-API-KEY": f"{api_key}",
    "Content-Type": "application/json"
}

response = requests.get(url, headers = headers)

if response.status_code == 200:
    print(response.json())
else:
    print(f"Request failed with status code: {response.status_code}")

The most important part:

Code:
headers = {
    "X-API-KEY": f"{api_key}",
    "Content-Type": "application/json"
}

Presented more simply:

Code:
headers = {
    "X-API-KEY": "00000000",
    "Content-Type": "application/json"
}



Our Rest Api Tool: (Your Api Key is save) - Full Version: API Tester



Browser extension test: (Talend API Tester Website: https://chromewebstore.google.com/detail...liamlcdmfm)

   
Please use: X-API-KEY and not  X_API_KEY


Or simpler, online web service: https://httpie.io/ (click Go to App)

   
   
Please use: X-API-KEY and not  X_API_KEY


Server:

If you want to allow requests for your project, you can activate CORS in your PHP script. (server side)
Simple call the functions cors() each time.

PHP Code:
<?php 
function cors() {
   
   
// Allow from any origin
    if (isset($_SERVER['HTTP_ORIGIN'])) {
        // Decide if the origin in $_SERVER['HTTP_ORIGIN'] is one
        // you want to allow, and if so:
        header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Max-Age: 86400');    // cache for 1 day
    }
   
   
// Access-Control headers are received during OPTIONS requests
    if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
       
       
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
            // may also be using PUT, PATCH, HEAD etc
            header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
       
       
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
            header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
   
       
exit(0);
    }
   
   
echo "You have CORS!";
}

Print this item

  LED Sports + Stock Ticker
Posted by: TheSportsDBFan - 08-16-2024, 11:51 PM - Forum: Presentation of your projects - No Replies

Desk sized LED ticker that could display all kinds of information. From stock, crypto, forex prices, to news, weather and finally sports! The ticker consists of two 64x32 P3 LED matrix panels, a Raspberry Pi 3 A+, 5V 14A power supply and a custom 3D printed frame to put all the parts together.

Website: https://fintic.io/
Instagram: https://www.instagram.com/fintic.io/



Attached Files Thumbnail(s)
   
Print this item

  Python SDK for TheSportsDB.com (Tralah)
Posted by: TheSportsDBFan - 08-16-2024, 11:36 PM - Forum: Presentation of your projects - No Replies

Python SDK to connect to the api of https://thesportsdb.com/ - TheSportsDB Python SDK

Download: Github: https://github.com/TralahM/thesportsdb
Developer: Tralah M Brian
Github Profile: https://github.com/TralahM

Print this item

  PHP Library for TheSportsDB.com (Nikolai)
Posted by: TheSportsDBFan - 08-16-2024, 11:27 PM - Forum: Presentation of your projects - No Replies

PHP Library to connect to the api of https://thesportsdb.com/ - TheSportsDB PHP library

Download: Github: https://github.com/nkl-kst/the-sports-db
Developer: Nikolai Keist
Github Profile: https://github.com/nkl-kst

Features:

- Get data for lists, livescores, lookups, schedules, searches or video highlights 
- Get results in serialized classes 
- Use your own API key 
- Throttle long-running scripts 
- Use PSR-4 autoloading 
- Supports PHP 7.4+

Print this item

  Game - Not Football League (mknoll1)
Posted by: TheSportsDBFan - 08-16-2024, 11:16 PM - Forum: Presentation of your projects - No Replies

A litte browser game.

Website:  https://knollfear.github.io/NotNFL/
Developer: mknoll1
Github Profile: -



Attached Files Thumbnail(s)
   
Print this item

  TV Guide (cysports)
Posted by: TheSportsDBFan - 08-16-2024, 11:09 PM - Forum: Presentation of your projects - No Replies

This is designed to be a progressive web-app so looks best on a mobile device (if you're running an iPhone, you can save this to your homescreen and it will work as an app)

Website: https://www.cysports.co.uk/
Developer: cysports
Buy me a coffee: https://buymeacoffee.com/cysports



Attached Files Thumbnail(s)
   
Print this item

  Screensaver (enen92)
Posted by: TheSportsDBFan - 08-16-2024, 11:01 PM - Forum: Presentation of your projects - No Replies

A football panel made for Kodi. Livescores, League tables and RSS feeds as a screensaver or program addon. Fully customizable, each item is updated on time intervals and scrolls through the screen. Presents the team logos, score, goal details, time and redcards. Powered by https://www.thesportsdb.com

Download: Github: https://github.com/enen92/script.screensaver.football.panel
Developer: enen92
Github Profile: https://github.com/enen92
Support: https://forum.kodi.tv/showthread.php?tid=258252



Attached Files Thumbnail(s)
   
Print this item

  Python Module for TheSportsDB.com (enen92)
Posted by: TheSportsDBFan - 08-16-2024, 10:55 PM - Forum: Presentation of your projects - No Replies

A python module packaged as a Kodi script module to wrap all thesportsdb API methods and for you to use on your own addon. 
An API key is required.

Download: Github: https://github.com/enen92/script.module.thesportsdb
Developer: enen92
Github Profile: https://github.com/enen92

Print this item

  PHP Library for TheSportsDB.com (Jelle)
Posted by: TheSportsDBFan - 08-16-2024, 10:48 PM - Forum: Presentation of your projects - No Replies

PHP Library to connect to the api of https://thesportsdb.com/

Download: Github: https://github.com/Jelle-S/TheSportsDb
Developer: Jelle Sebreghts
Github Profile: https://github.com/Jelle-S

Example Code:

PHP Code:
<?php

include_once __DIR__ . '/default_bootstrap.php';

// Get all sports.
$sports = $db->getSports();

// Print the first sport.
$sport = reset($sports);
print_r($sport->raw());

// Get the leagues of this sport (lazy loaded).
$leagues = $sport->getLeagues();

// Print the first league.
$league = reset($leagues);
print_r($league->raw());

// Get the seasons for this league.
$seasons = $league->getSeasons();

// Print the first season.
$season = reset($seasons);
print_r($season->raw());

// Get the events for this league.
$events = $season->getEvents();

// Print the first event.
$event = reset($events);
// Trigger lazy load, the full event object will be loaded when calling $event->raw().
$event->getName();
print_r($event->raw());

Print this item

  Software: Kodi
Posted by: TheSportsDBFan - 08-15-2024, 08:43 PM - Forum: Kodi - No Replies

Software: Kodi
Source: https://kodi.tv/

[Image: software07.jpg]

Please create your own topics and do not post here.

Print this item

Latest Download Submissions Go to All Downloads
Web - My Sports Handbook (g36mitchell) - Submitted by TheSportsDBFan
Submit Date: 08-22-2024, 08:30 PM | Category: Tools and Scripts
PlexSportScanner (Project-Plex) V.0.9.1 - Submitted by TheSportsDBFan
Submit Date: 08-21-2024, 09:54 PM | Category: Plex Plugins
The Sports Database Python- metadata.thesportsdb.python V.1.1.7 - Submitted by TheSportsDBFan
Submit Date: 08-21-2024, 09:16 PM | Category: Kodi Addons
PHP TSDB TV-Guide (Vilhao) - Submitted by TheSportsDBFan
Submit Date: 08-20-2024, 08:53 PM | Category: Tools and Scripts
Texturecache.py V.1.0.0 - Submitted by TheSportsDBFan
Submit Date: 08-16-2024, 10:15 PM | Category: Tools and Scripts