Yacy API and Peer-Proxy for PHP

Configuration
Edit YaCyAPI.php to define available YaCy-peers which should be contacted while doing search-querys.
Define only one or use choosePeer(peerno) method for one single peer.
...
public function getResults() {

     // ----------- edit here ----------
 
     // array of possipble peers  0:ip, 1:port, 2:user:pw, 3: opt.friendlyname
     // do NOT use localhost but (public) IP/hostname
     $this_YaCyPeer[0][0]="mypeer1.tld";                            $this_YaCyPeer[0][1]="8080"; $this_YaCyPeer[0][2]="admin:password";
     $this_YaCyPeer[1][0]="
mypeer2.tld";                            $this_YaCyPeer[1][1]="8081"; $this_YaCyPeer[1][2]="admin:password";$this_YaCyPeer[1][3]="some comments"
    
     $this_maxpeers=2;
     // ----------- end edit ----------
 

Download
YaCyAPI.php
yapp.php (examples)

MultiMedia-Mashup, demo search application

Usage for search
Simple search auto-selecting peer and delivering raw xml/json if called like yacysearch.rss
?s=testword

<?php
// Include the API PHP Library
require 'YaCyAPI.php';

// search example
$searchWeb=$_SERVER["QUERY_STRING"];     # query must be: ?s= or ?search=

    $search->query($searchWeb)
           ->setSources('Web')
           ->setFormat('xml')
           ->setOptions(array(
                            'resource' => 'local',
                            'maxRecords' => '17',
                            'verify' => 'false'));

    // Contains the search
    $results = $search->getResults();
   
   //echo raw XML
    echo $results;
?>


Usage as proxy:
Proxy is auto-selecting peer and delivering raw xml/json if called like yacysearch.rss
?query=testword&display=0 ...

<?php
// proxy example

$searchWeb=$_SERVER["QUERY_STRING"];     # for proxy pass all params

    $search->query($searchWeb)
           ->setSources('Web')
           ->setFormat('xml');
           #->choosePeer("2");
          
    // Contains the search
    $results = $search->getResults();
   
    // deliver source only
    echo $results;
?>   

Usage for peer steering and status:
Proxy is using selected peer for html-commands and xml-status 

<?php
// pause local crawl
$command="Status.html?pauseCrawlJob=&jobType=localCrawl";
$peerno="0";
$search->peerCommand($peerno,$command);



// get xml-status
$command="Network.xml";
$peerno="0";
$xml = $search->peerCommand($peerno,$command);
//parse xml...