It seems some of the Freebase API examples are broken. Thanks to Bart for the heads up.
(Update Nov 07 - Freebase no longer requires an account for read access. So the cookie is probably unnecessary. )
Here are the most basic steps to getting started with Freebase PHP:
- Check your webserver runs PHP
- Download TestFreebasePHP.php to your webserver.
- View the PHP script through your server, you should see ‘Query failed’
- Check you are logged into your Freebase account.
- Get your metaweb-user cookie. (With Firefox: Preferences, Privacy, Show Cookies, search ‘Freebase’). It should look like this:
metaweb-user="Z|a_aaaaaaaaaa|a_#1111a1a1111...snip...ZaaZZaZZ1aZ/ZZ"
- Test your cookie using this shell one-liner
- Edit TestFreebasePHP.php and replace the dummy cookie with your own.
- View the PHP script through your web server. If you see ‘Query succeeded’ then all is well.
I challenge you to come up with a smaller test script!
You can see the script running successfully on my server:
Test Freebase access using PHP
Loading: http://www.freebase.com/api/service/mqlread?q={"query":[{"id":"/type/int"}]}
Query succeeded
Response:
{
"status": "200 OK",
"query": {},
"code": "/api/status/ok",
"messages": [],
"result": {
"query": [
{
"id": "/type/int"
}
]
}
}
July 5, 2007 at 10:18 am |
[...] Freebase API – cookie test Here is one line shell script to test your Freebase cookie. (Replace the dummy cookie with your own cookie): [...]
July 5, 2007 at 10:35 am |
[...] (Have you followed the steps in Getting started with Freebase and PHP?) [...]