Jump to content

API_PHP

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by API_PHP

  1. Hey, some background: I made a metasearch engine (mainly using PHP), where the results from Bing, Yahoo, and Google are aggregated and displayed in one list. If a document appears in more than one engine it receives a more favourable rank. This has been made for a university assignment and is for educational purposes. Based on a test of 50 queries from the Trec 2012 Web Track, this engine performs approximately 12% better (in terms of relevant results) than the highest performing individual engine (Google). I would like you to view, and test the application, at http://www.metasearch.me . There is a page where you can leave feedback via a form..I would appreciate if you could do this, which will aid me greatly in the generation of my written report. The user interface design is not necessarily the most important feature of this application (worth 4% of the marks), more important elements include the usability and the functional of the site. Anyway, thanks for looking.
  2. I have 3 arrays, each containing a dynamically generated list of documents. (The list changes depending on what the user searches for) $list1['documentname'] $list2['documentname'] $list3['documentname'] Each array is multidimensional and contains other information such as description. $list1 = array('documentname','description') For example if I wanted to output the sixth document`s name and description I would write: echo $list1[5]['documentname'].$newline.$list1[5]['description']; A particular document may be contained in all three lists or none of the lists. What I am trying to do is rank the documents by the documents total score using the following formula: $document_Score = (1/(60+rank_list1)) + (1/(60+rank_list2)) + (1/(60+rank_list3)) I am trying to think of a way of doing this but I am getting nowhere. If document a is ranked 1 in list1, 2 in list2, and 4 in list3, how do I apply the following formula and add the scores together. $document_Score = (1/(60+1)) + (1/(60+2)) + (1/(60+4)) //score for document a I know that I need to apply code based on whether $list1['documentname'] is equal to $list2['documentname'] etc but I have no idea how to implement this. Any tips or ideas would be appreciated. Any ideas? Thanks.
  3. Good afternoon, I am able to retrieve results from yahoo with my API key, using the instructions found here: http://developer.yahoo.com/boss/search/boss_api_guide/codeexamples.html# Code: <?php require("OAuth.php"); $cc_key = "your consumer key here"; $cc_secret = "your consumer secret here"; $url = "<http://yboss.yahooapis.com/ysearch/news>,web,images"; $args = array(); $args["q"] = "yahoo"; $args["format"] = "json"; $consumer = new OAuthConsumer($cc_key, $cc_secret); $request = OAuthRequest::from_consumer_and_token($consumer, NULL,"GET", $url, $args); $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL); $url = sprintf("%s?%s", $url, OAuthUtil::build_http_query($args)); $ch = curl_init(); $headers = array($request->to_header()); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $rsp = curl_exec($ch); $results = json_decode($rsp); print_r($results); ?> However the output of results is very bizarre, for example, if I search for elephant, I get the following results (partial copy and paste): stdClass Object ( [bossresponse] => stdClass Object ( [responsecode] => 200 [images] => stdClass Object ( [start] => 0 [count] => 35 [totalresults] => 108000 [results] => Array ( [0] => stdClass Object ( [clickurl] => http://0.tqn.com/d/goafrica/1/0/Y/Q/IMG_1592.JPG [size] => 2.2MB [format] => jpeg [height] => 2432 [refererclickurl] => http://goafrica.about.com/od/africanwildlife/ss/The-Big-5-Images-Facts-And-Information-About-Africas-Big-Five_2.htm [refererurl] => http://goafrica.about.com/od/africanwildlife/ss/The-Big-5-Images-Facts-And-Information-About-Africas-Big-Five_2.htm [title] => African Elephant - One of the "Big Five" - African Elephant Image ... [url] => http://0.tqn.com/d/goafrica/1/0/Y/Q/IMG_1592.JPG [width] => 2591 [thumbnailheight] => 150 [thumbnailurl] => http://ts2.mm.bing.net/th?id=H.4700108340594617&pid=15.1&H=150&W=160 [thumbnailwidth] => 160 ) [1] => stdClass Object ( [clickurl] => http://images.nationalgeographic.com/wpf/media-live/photos/000/004/cache/african-elephant_435_600x450.jpg [size] => 54.1KB [format] => jpeg [height] => 450 [refererclickurl] => http://animals.nationalgeographic.com/animals/photos/elephants/ [refererurl] => http://animals.nationalgeographic.com/animals/photos/elephants/ [title] => Elephant Pictures - National Geographic [url] => http://images.nationalgeographic.com/wpf/media-live/photos/000/004/cache/african-elephant_435_600x450.jpg [width] => 600 [thumbnailheight] => 120 [thumbnailurl] => http://ts2.mm.bing.net/th?id=H.5058106677789309&pid=15.1&H=120&W=160 [thumbnailwidth] => 160 ) [2] => stdClass Object ( [clickurl] => http://www.splendidwallpaper.com/wp-content/uploads/2010/03/baby_elephant_1024x768.jpg [size] => 149.4KB [format] => jpeg [height] => 768 [refererclickurl] => http://www.splendidwallpaper.com/baby-elephant-2102/ [refererurl] => http://www.splendidwallpaper.com/baby-elephant-2102/ Please bear in mind that I am very new to php, and programming in general. I am completing a fast track learning course where we don`t have time to learn the basics, we are in the deep end! Does anyone have suggestions on how to display the results properly? Thanks! Note: I had tried to do it this way (which worked with the Google API - although the links were not clickable).. It did not work at all with Yahoo: foreach ($results->{ 'items' } as $item ) { echo $item->{ 'title' }.": ".$item->{ 'link' }."\n\n"; echo $newline; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.