alhrock / phptvdb

Automatically exported from code.google.com/p/phptvdb
0 stars 0 forks source link

Fix for Find_by_Id #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
thetvdb.com appearently changed one of the URLs used to find a show by its
ID number. An API key is no longer needed. Here are the changes I made to
TVDB/TV_Shows.class.php

I added 

CONST tvdbUrl = 'http://thetvdb.com/';

just above 

CONST tvdbUrl = 'http://thetvdb.com/';

and then I changed a line in request so it looks like this now

protected function request($params) {

      switch($params['action']) {

        case 'show_by_id':
          $id = $params['id'];
          $url = self::tvdbUrl.'data/series/'.$id.'/';

          $data = self::fetchData($url);
          return $data;
        break;

it's the $url line that I changed.

I had previous changed by code using the fixes listed on the issues list before

Original issue reported on code.google.com by senorsma...@gmail.com on 24 Mar 2009 at 12:38

GoogleCodeExporter commented 8 years ago
I downloaded a fresh copy of the PHP and made the changes above and received the
following error.

Fatal error: Cannot use object of type TV_Show as array in
/home/*/public_html/test2/test.php on line 8

test.php

6    $tvShows = TV_Shows::findById(76290); 

8    $tvShow = $tvShows[0];

Original comment by Iveo...@gmail.com on 24 Mar 2009 at 12:32

GoogleCodeExporter commented 8 years ago
I don't have that test file, but FindById should only return one TV_Show 
object, not
an array of TV_Show objects.

Original comment by senorsma...@gmail.com on 24 Mar 2009 at 7:36

GoogleCodeExporter commented 8 years ago
try this instead

$tvShow = TV_Shows::findById(76290); 

Original comment by senorsma...@gmail.com on 24 Mar 2009 at 7:37

GoogleCodeExporter commented 8 years ago
changing that gives me

Fatal error: Call to a member function getEpisode() on a non-object in
/home/usenettv/public_html/test/test.php on line 17

I have attached the test file. It's mainly the example from Ryan's test site.

This used to work beautifully lol

Original comment by Iveo...@gmail.com on 24 Mar 2009 at 11:31

Attachments:

GoogleCodeExporter commented 8 years ago
try deleting this line
$tvShow = $tvShows[0];

Original comment by senorsma...@gmail.com on 25 Mar 2009 at 12:29

GoogleCodeExporter commented 8 years ago
That's working perfectly now!

Although....

Now for some reason $tvShow->dayOfWeek no longer brings up a value. Is this a 
side
effect of the changes TheTVDB have made?

Original comment by Iveo...@gmail.com on 25 Mar 2009 at 10:41

GoogleCodeExporter commented 8 years ago
Found the problem.

TV_Show.class.php

Before change:

public $dayOfWeek;

$this->daysOfWeek = (string)$config->Airs_DayOfWeek;

Change to:

public $dayOfWeek;

$this->dayOfWeek = (string)$config->Airs_DayOfWeek;

That fixes it fine.

Is it possible for the community to rewrite some of this code now we've made 
changes?

Original comment by Iveo...@gmail.com on 25 Mar 2009 at 10:45

GoogleCodeExporter commented 8 years ago
Hi, I just found out that people are filing issues, I wasn't receiving any 
emails.
I'll look into this problem. 

Original comment by ryan.doherty on 27 Mar 2009 at 5:13

GoogleCodeExporter commented 8 years ago
I've updated some code in 1.0.2, which is available for download. Included 
dayOfWeek
fix and new url for tv show information.

Original comment by ryan.doherty on 27 Mar 2009 at 7:27