Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:20:48+00:00 2026-06-16T03:20:48+00:00

As i said in the title i am using through php the json api

  • 0

As i said in the title i am using through php the json api for twitch tv and own3d tv to get the information of the stream i want.

Ths problem is that the page is not loading fast, as a matter of fact some times the php server stops because of 30 or more secs of function.
The error : Fatal error: Maximum execution time of 30 seconds exceeded in

I am using an online indicator :

 function status($stream_id, $type){
if($type == 't'){

    $chan = "http://api.justin.tv/api/stream/list.json?channel=" . $stream_id;
    $json = file_get_contents($chan);
    $exist = strpos($json, $stream_id);
    if($exist) {
        return true;
    }else{
        return false;   
    }


}else if($type == 'o'){

    $url = 'http://api.own3d.tv/liveCheck.php?live_id=' . $stream_id;
    $xml = simplexml_load_file($url);

    $isLive=$xml->liveEvent->isLive;

    if ($isLive == "true") {
        return true;
    }else{
        return false;   
    }

}
}

and i am using a function that get some info from the stream :

function api_stream_data($stream_id, $type){
$stream_id = sanitize($stream_id);
$type = sanitize($type);

if($type == 't'){

    $streamData = json_decode(file_get_contents("http://api.justin.tv/api/stream/list.json?channel=$stream_id"),true);

    $data = array(
        'image'=>$streamData[0]['channel']['image_url_medium'],
        'title'=>$streamData[0]['title'],
        'limage'=>$streamData[0]['channel']['screen_cap_url_huge'],
        'game'=>$streamData[0]['meta_game']
    );
}else if($type == 'o'){
    $streamData = json_decode(file_get_contents("http://api.own3d.tv/rest/live/list.json?liveid=$stream_id"),true);
    $data = array(
        'image'=>$streamData[0]['thumbnail_small'],
        'title'=>$streamData[0]['live_name'],
        'limage'=>$streamData[0]['thumbnail_large'],
        'game'=>$streamData[0]['game_name']
    );
}

return $data;

}

All functions works perfectly but the problem is the time they get to excecute….

Is there any possible way to do that faster??
I have seen some other site examples that are loading very fast like http://www.solomid.net and http://www.clgaming.net .

Thanks in advance for any help!

EDIT: *SOLVED* Thank’s each and every one of you for your help! I used a cronjob that stores the data to the database and then i just made a query to request them, it updates every 5 mins but, oh well, better than nothing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:20:49+00:00Added an answer on June 16, 2026 at 3:20 am

    Your code is slow becuase you are doing one http request per user. Just one http request usually takes arround 200ms-400ms. PHP is not asynchronous, this means that is going to stop the execution of your code until it gets a response from own3d or twitch.

    I’m not familiar with the own3d api, but in Twitch you can send all the users id you want and it will fetch you all the details in one single http request.

    This is how I’m doing the fetching of twitchtv live streams on my site.

    Example:

    $response = $client->get(”, ”, ‘http://api.justin.tv/api/stream/list.json?channel=’.implode(‘,’, $users));

    This would generate the following url:
    http://api.justin.tv/api/stream/list.json?channel=IPLLoL,tsm_theoddone,KungenTV

    This way you can fetch all your user’s streams in one single http request.

    I’ll suggest that since you are already identifying to which stream provider the stream belongs, instead of doing the http request, create an array, one for each stream provider and add the stream to the corresponding one.

    In the end make an http request, one for all the streams on the own3d array, and one for all the streams in the twitchtv array. Now you’ll have all your user’s streams with only two http requests.

    Oh and another thing. Do not do this stream fetching stuff when you are rendering your site, I have all this streams fetching stuff in ajax, that way, my page will load first and then it will start doing the http request after my site has been rendered.

    Also caching the response that twitch and own3d sends you is a good idea. That way you will not be fetching data for own3d and twitch on every user that visits your site. This is great speacially if you have some solid traffic.

    That should really improve the speed. I hope this would help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title said: Is it possible to send an email (using php mail())
all is said in the title, I want to get from an element all
As said in the title i want to stop Hibernate console output, without using
    As the title said, I want to match ip address with batch in windows,
as title said, Im trying to change only the first occurrence of word.By using
As the title said, I want to debug some Core Data bugs. Instead of
Trying to get this form to validate email using the function the professor said
As you might heard in the title I'm using PHP to add info to
As the title states, I want to get the difference (in seconds) between 2
like said in the title I'd like to change a button's backgroun (using setBackgroundResource()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.