doumicheng6732 2015-09-22 03:45
浏览 12
已采纳

用PHP读取的文件内容

I can obtain information form google books in PHP using the following code

 $page1 = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:1933372826")
 $data = json_decode($page1, true);

I have an array of 1,200+ ISBNs so I want to be able to get this files so I can read it

So for example if I get each element of the array that is ISBN to be $book_isbn I tried the following but I get an error

 $page2 = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:$book_isbn")
 $book_data = json_decode($page2, true);

What should I change? Can I have $book_isbn in the file_get_contents?

This is the error I get

 Parse error: syntax error, unexpected '$book_data' (T_VARIABLE)
  • 写回答

1条回答 默认 最新

  • duanfu1942 2015-09-22 03:53
    关注

    You can use

    $book_isbn = '1933372826';
    $page2 = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:$book_isbn");
    $book_data = json_decode($page2, true);
    echo '<pre>';print_r($book_data);
    

    If you have multiple value of book_isbn then use foreach and iterate over each element.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题