[Developers] PHP Integration Problems

Chris Mahon darthmahon at gmail.com
Tue Jan 1 10:15:05 UTC 2008


Hi,
I'm currently building a search page for computer games and have come across
some teething problems whilst using freebase.

$q = array(
"type" => "/cvg/cvg_platform",
"name" => "Xbox 360",
"games_on_this_platform" => array("game" => array("name" => null))
);

This is the query I based that on from within the freebase query builder:

[{

"type":"/cvg/cvg_platform",

"games_on_this_platform":[{ "game":[{ "name":null }] }],

"name":"Xbox 360"

}]


My PHP script is fairly simple, but it throws up an error "*Warning*:
Invalid argument supplied for foreach()", but this only happens on this
query. I have other queries I have tested like being able to search for a
particular game and that works fine. PHP script below:

<?php

require("metaweb.class.php");
$count = 0;
$results = array();
$mw = new Metaweb();

$q = array(
"type" => "/cvg/cvg_platform",
"name" => "Xbox 360",
"games_on_this_platform" => array("game" => array("name" => null))
);

$auth = 'XXXXXXXXXX';

$results = $mw->read($q, $auth);
$count = count($results);

?>

<?php foreach ($results as $game) : ?>
     <li><?=$game['name']?>
(<?=$game['games_on_this_platform']['game']['name']?>)</li>
<?php endforeach; ?>

Any ideas as to why I get results in the query builder but not in PHP,
seeing as the query is the same?

I've also mentioned this in the discussions board on freebase but I think it
would be good if freebase pages had a link to the MQL query that was used to
generate the data on that particular page. For example, this page (
http://www.freebase.com/view/reorder/topic/en/xbox_360?propertyId=%2Fcvg%2Fcvg_platform%2Fgames_on_this_platform)
does pretty much what I want to do, but has some missing fields etc. It
would be good for developers to be able to quickly see how that was
generated and would shorten the learning curve dramatically.

Thanks,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20080101/12549eb5/attachment.htm 


More information about the Developers mailing list