HIRING: QUICK Job with PHP/XML - useYahoo BOSS api (Search engine API) **$15 Paypal**

Discussion in 'Programming' started by ZachF, Oct 25, 2010.

  1. #1
    edit: done, thanks
     
    Last edited: Oct 25, 2010
    ZachF, Oct 25, 2010 IP
  2. ZachF

    ZachF Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    edit: done, thanks
     
    Last edited: Oct 25, 2010
    ZachF, Oct 25, 2010 IP
  3. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    something like this ?:

    
    <?php if ($_GET['s'] == '') { ?>
    <form method="get" style="margin-bottom:30px; margin-top:20px;">
    <input type="text" name="s" size="30" /> <input type="submit" value="Search" />
    </form>
    <?php } ?>
    
    <?php
    if ($_GET['s'] != '') {
    
    // connect to database
    if(@mysql_connect('localhost', 'user', 'pass'))
    {
    	if(@mysql_select_db('yahooboss'))
    	{
    		$db_connected = true;
    	}
    }
    // end_mysql_connect
    
    //Gather data and prepare query
    $thequery = urlencode($_GET['s']);
    $yhost = 'http://boss.yahooapis.com';
    $apikey = 'YOUR KEY HERE';
    $url = $yhost.'/ysearch/web/v1/'.$thequery.'?appid='.$apikey.'&format=xml&view=keyterms';
    echo "<a href='$url'>$url</a><br>";
    //Get the results
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    $results = new SimpleXmlElement($data, LIBXML_NOCDATA);
    
    //echo the results
    $related_cache = array();
    
    foreach ($results->resultset_web->result as $theresult) {
    echo '<a href="'.$theresult->clickurl.'">'.$theresult->title.'</a><br/>';
    echo $theresult->abstract.'<br/>';
    echo '<small><i>'.$theresult->dispurl.'</i> </small>
    <br/>';
    
    echo 'Related: ';
    if(isset($theresult->keyterms->terms->term))
    {
    	$rels = array();
    	foreach($theresult->keyterms->terms->term as $rel)
    	{
    		$rl_key = md5(strtolower($rel));
    		if(isset($related_cache[$rl_key])) continue;
    		
    		$rels[] = $rel;
    		$related_cache[$rl_key] = $rel;
    	}
    	echo implode(', ', $rels);
    	
    	if(isset($db_connected) && !empty($rels))
    	{
    		$query = "INSERT INTO related(`keyword`) VALUES ('";
    		$query .= implode("'), ('", $rels);
    		$query .= "')";
    		mysql_query($query);
    	}
    	
    }
    echo '<br/><br/>';
    }
    
    }
    ?>
    
    
    PHP:
     
    Last edited: Oct 25, 2010
    gapz101, Oct 25, 2010 IP
  4. ZachF

    ZachF Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    That could do it, i'll pm you let me mock up the mysql insertion and see if it's what i wanted. From a quick glance it seems to be good!
     
    ZachF, Oct 25, 2010 IP
  5. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    where is money?
     
    gapz101, Oct 27, 2010 IP