TheTVDB.com

Online TV Database
It is currently Thu May 23, 2013 12:22 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Feb 24, 2012 9:59 pm 
Offline

Joined: Fri Feb 24, 2012 9:46 pm
Posts: 5
Code:
var showURL= mirror + "api/GetSeries.php?seriesname=" + show + "&language=" + lang;

   if (window.XMLHttpRequest)
     {// code for IE7+, Firefox, Chrome, Opera, Safari
     xmlhttp=new XMLHttpRequest();
     }
   else
     {// code for IE6, IE5
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
    
   xmlhttp.open("GET",showURL,false);
   xmlhttp.send();
   xmlDoc=xmlhttp.responseXML;
   



For this code execution i am getting the error :

Quote:
NETWORK_ERR: XMLHttpRequest Exception 101


Probably because of Cross domain restrictions ? And yes i could not yet figure where to use my api key.


Top
 Profile  
 
PostPosted: Sat Feb 25, 2012 8:25 am 
Offline

Joined: Tue Feb 14, 2012 2:42 pm
Posts: 4
I'm fairly sure you can't access data from an external server with an XMLHttpRequest.

There's some solutions to the issue here.


Top
 Profile  
 
PostPosted: Sat Feb 25, 2012 2:53 pm 
Offline

Joined: Fri Feb 24, 2012 9:46 pm
Posts: 5
yep i read that too. probably i am still having issues in understanding the tvdb api. can you pls let me know how can i download the tvdb .. and where shall i use my api key.. there is no clear documentation on tvdb api so i am bit confused.. also pls let me know if the api works well for javascript.


Thank you


Top
 Profile  
 
PostPosted: Sat Feb 25, 2012 2:59 pm 
Offline
Site Moderator

Joined: Sat Oct 16, 2010 5:48 pm
Posts: 1093
Location: England
Everything you should need to get you started is on the wiki: http://www.thetvdb.com/wiki/index.php/Programmers_API

As far as I know for JavaScript apart from a few possible workarounds, like with any other 3rd party api you won't be able to access it directly, you'll need to have something on your server fetch the api content and make it available to your JavaScript code (in effect a proxy). This is due to the cross domain restrictions in browsers.

_________________
---

Please watch this video to help LSU Computer Society try to win the RBS ESSA society competition! http://youtu.be/8JrhmoSXLXw - only 1:36min

Thanks :D


Top
 Profile  
 
PostPosted: Sun Feb 26, 2012 8:20 pm 
Offline

Joined: Fri Feb 24, 2012 9:46 pm
Posts: 5
I am still not able to get anything fruitful from the API wiki. May be i am a naive developer .

Anyways, i could not find the database for Series. Do i need to create a replcia of db on my local machine and then use api calls ?

What i need to do is:

1. Provide a user interface for entering a show.
2. For that selected show i form a URL using the code

var mirror="http://thetvdb.com/";
var showURL= mirror + "api/GetSeries.php?seriesname=" + show + "&language=" + lang;

3. Now i am generating an XML file here which i can see on browser but when i try to get this xml file into a string, my code fails.


also i am doubtful this might be happening because there is no place where i was required to use my API Key,

Please suggest ...


Top
 Profile  
 
PostPosted: Mon Feb 27, 2012 6:04 am 
Offline
Site Moderator

Joined: Sat Oct 16, 2010 5:48 pm
Posts: 1093
Location: England
vasujain wrote:
I am still not able to get anything fruitful from the API wiki. May be i am a naive developer .

Anyways, i could not find the database for Series. Do i need to create a replcia of db on my local machine and then use api calls ?

No, all the calls are documented under "File Structure" & "Example Usage" on http://www.thetvdb.com/wiki/index.php/Programmers_API. If you do want a snapshot of the entire database you are able to get one from a topic on the forums somewhere but these are rarely needed by developers and you still need to use the api to keep upto date.

vasujain wrote:
What i need to do is:

1. Provide a user interface for entering a show.
2. For that selected show i form a URL using the code

var mirror="http://thetvdb.com/";
var showURL= mirror + "api/GetSeries.php?seriesname=" + show + "&language=" + lang;

3. Now i am generating an XML file here which i can see on browser but when i try to get this xml file into a string, my code fails.

As has been pointed out above this is due to cross domain restrictions in browsers. This stops javacript from somedomain1.com calling a file from somedomain2.com. To get around this you will probably need to implement a server side proxy on your site (using php/asp/perl/python etc). This will mean your data flow goes: javascript on webpage -> your local proxy -> thetvdb.com api and back again. If you google "javascript cross domain" you'll get a load of pages explaining the browser limitations and possible solutions. We can help with API related issues but we won't be able to help you implement an intermediate proxy to be able to access the api from javascript


vasujain wrote:
also i am doubtful this might be happening because there is no place where i was required to use my API Key,

Please suggest ...

As documented on the wiki page, not all the calls require api keys, for example step 3 doesn't but step 4 does:
Quote:
Step 3: Loop through and look up each series id

a. Retrieve http://www.thetvdb.com/api/GetSeries.php?seriesname=<series name from your database>

b. Optionally present results to user so they can select the match they want.

c. Store this series id in a table in your database.


Quote:
Step 4: Get base information for each series

a. Retrieve <mirrorpath_zip>/api/<apikey>/series/<seriesid>/all/<language>.zip and extract <language>.xml and banners.xml.

b. Process the XML data in <language>.xml and store all <Series> data.

c. Download each series banner in banners.xml and prompt the user to see which they want to keep.

Note: Make sure you record <id> from each series, since it's returned in updates as <Series>.

_________________
---

Please watch this video to help LSU Computer Society try to win the RBS ESSA society competition! http://youtu.be/8JrhmoSXLXw - only 1:36min

Thanks :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group