Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad Json data with php giving an error
    text
    copied!<p>I am using this code to try to get json data from many json files using yql to compile them into one json. </p> <p>My yql query is in this format:</p> <pre><code>select * from json where url="http://ebird.org/ws1.1/data/obs/region_spp/recent?rtype=subnational2&amp;r=US&amp;sci=Dendrocygna%20autumnalis&amp;fmt=json" or url = "http://ebird.org/ws1.1/data/obs/geo_spp/recent?lng=-119.859512&amp;lat=34.410240&amp;sci=Dendrocygna%20autumnalis&amp;dist=49&amp;back=14&amp;maxResults=10000&amp;fmt=json&amp;includeProvisional=true" and itemPath = "json.json" </code></pre> <p>I <code>rawurlencode</code> the above to obtain the <code>q=</code> part of the yql query url. Then i get this outputted url. It works fine when copy and paste the echoed url into my browser, but when i try to use <code>file_get_contents</code> on the url I get this:</p> <pre><code>cbfunc({"error":{"lang":"en-US","diagnostics":{"publiclyCallable":"true"},"description":"Query syntax error(s) [line 1:3675 missing EOF at '_']"}}); </code></pre> <p>So I am asking, why does it not work when I am using it with <code>file_get_contents</code>, but does when I am using the url in my browser. Also, is there a smarter/easier way to use multiple json files together with php? I tried using curl to pull the yql json and got a weird output like:</p> <pre><code>8&lt;\/howMany&gt;34.4136&lt;\/lat&gt;-119.8756&lt;\/lng&gt;L615794 </code></pre> <p>This method would be fine, but I don't know how to get it into a useable array.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload