Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

byIsbn method sometimes return null #6

Open
mdeprezzo opened this issue Jan 30, 2018 · 16 comments
Open

byIsbn method sometimes return null #6

mdeprezzo opened this issue Jan 30, 2018 · 16 comments

Comments

@mdeprezzo
Copy link

HI,
i notice that sometime, the byIsbn method from Voumes class, return null. But from google books api console, i see the results. So i need to delete the string 'isbn' and now work fine. Any suggestions ?

@josephmancuso
Copy link
Contributor

josephmancuso commented Jan 30, 2018

I believe when you loop through this, you'll need to check if it is not null before displaying it since you obviously can't echo null

@mdeprezzo
Copy link
Author

The point is, if i remove 'isbn:' works fine, i can find the books. But if i restore that string, null is the result.

@josephmancuso
Copy link
Contributor

Can you post your code?

@mdeprezzo
Copy link
Author

mdeprezzo commented Jan 30, 2018

Sure, i simply make a call to findByGoogleBooks:

	/**
	 * @param GoogleBooks $googlebooks
	 */
	public function __construct(GoogleBooks $googlebooks)
	{
		$this->googlebooks = $googlebooks;
	}

	/**
	 * Attempt to find a book by isbn from google books
	 * 
	 * @param String $isbn
	 * @return Response
	 */
	public function findByGoogleBooks($isbn)
	{
		return $this->googlebooks->volumes->byIsbn($isbn);
	}	

Maybe i need to call search instead of byisbn

@josephmancuso
Copy link
Contributor

josephmancuso commented Jan 30, 2018

that method only takes the ISBN. https://github.com/scriptotek/php-google-books/blob/master/src/Volumes.php#L41

I believe what you are saying is you are doing something like:

...->findByGoogleBooks('isbn: 8ynsf...')

it should just be the isbn

...->findByGoogleBooks('8ynsf...')

since we prepend that isbn string. check the link to the Volumes class

@mdeprezzo
Copy link
Author

@josephmancuso i know, but with prefix 'isbn:' i have always null or empty data, returned from api. But in reality the books exists if i test the call with postman.

@josephmancuso
Copy link
Contributor

josephmancuso commented Jan 30, 2018

ahhh ok I see. So removing the 'isbn:' from the volumes class fixes the issue you're saying?

@danmichaelo

@mdeprezzo
Copy link
Author

@josephmancuso yep, maybe something is changed on google books api. But I could not understand why it did not work anymore, and to test it, i've tried to remove 'isbn:'.

@josephmancuso
Copy link
Contributor

josephmancuso commented Jan 30, 2018

hm it looks like the 'isbn:' still works via the google books api.

GET https://www.googleapis.com/books/v1/volumes?q=isbn%3A9780735619678&key={YOUR_API_KEY}

I'll test the actual code some time today. There are two PRs open that significantly change the API for this repo but a hot fix can work for the master branch. @danmichaelo is the owner

if you want to open a PR for the master branch go ahead. I'll test today.

@mdeprezzo
Copy link
Author

With italian isbn doesn't works yet, like 9788807902246

@josephmancuso
Copy link
Contributor

Well ISBN are international. That's what the I stands for. They're either 13 digits or 10 digits. I'll test both

@mdeprezzo
Copy link
Author

Of course, then maybe it's google books that has not added all the titles in the world in its archive? :D

@danmichaelo
Copy link
Member

danmichaelo commented Jan 30, 2018

Hm, this is quite interesting. If you look at the response for 9788807902246, it seems to refer to another book. Here's an excerpt:

    {
        "title": "Paddy Clarke ha ha ha",
        "authors": [
          "Roddy Doyle"
        ],
        "publishedDate": "1996",
        "industryIdentifiers": [
          {
            "type": "ISBN_10",
            "identifier": "8202160278"
          },
          {
            "type": "ISBN_13",
            "identifier": "9788202160272"
          }
        ],

At first I though it was the same book with another ISBN, but when I googled the same ISBN, I found the book Sull'Apocalisse. Testo latino a fronte by di Gioacchino da Fiore (2018) – a very different book.

So it seems like the Google Books API can return information about the wrong item if you just do a free query without the isbn: prefix. Do you have any other ISBN numbers we can test with?

@josephmancuso
Copy link
Contributor

josephmancuso commented Jan 30, 2018

@danmichaelo what was the exact query you put in? I actually noticed a discrepancy if there was a space between isbn: and the number. No space returned 1 result and a space returned like 1600 results

@mdeprezzo
Copy link
Author

mdeprezzo commented Jan 31, 2018

@danmichaelo Sure, give me a few minutes to make a list of problematic isbn.

here we go:

9788845426544
9788811689188

@danmichaelo
Copy link
Member

@danmichaelo what was the exact query you put in? I actually noticed a discrepancy if there was a space between isbn: and the number. No space returned 1 result and a space returned like 1600 results

The query can be found in the link I added ;) No key is needed. But the strange part is that I get a different (and seemingly correct) result now! Could it just have been a temporary problem at Google?

For 9788845426544 and 9788811689188 I get zero results both with and without the isbn: prefix, so that is not the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants