I am using a Bing library for search 2.0,
This is my script:
PHP Code:
[LEFT]<?php require_once '../bingapiphp-1.1/library/BingAPI.php';
$term=$_Request["term"]; $type=$_Request["type"]; $count=$_Request["count"]; $search = new BingAPI('AppID replaced for posting'); $search ->query("'".$term."'"); $search ->setSources("'".$type."'"); $search ->setFormat('json'); $search ->setOptions( array( $type.'.Count' => $count, $type.'.Offset' => '0', 'Adult' => 'Moderate', 'Options' => 'EnableHighlighting') );
$result = json_decode($search->getResults());
foreach($result->SearchResponse->$type->Results as $item) { echo(" <div class='Title'>$item[Title]</div> <div class='Description'>$item[Description]</div> <div class='Url'><a href='$item[Url]' target='_blank'>$item[Url]</a></div> <br> "); }[/LEFT] ?> [LEFT][/LEFT]
I am using the library because I got an error in my foreach statement, I get the same error with the library:
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\TickTach\php\search.php on line 25
I have tried replacing $type with a literal and I get the same error, so please do not focus on that... Can anyone tell me what the problem is?
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
|