コード例 #1
0
ファイル: test.php プロジェクト: rebe100x/YAKREP
<?php

require '../../PushAPI.inc';
require 'tick.inc';
try {
    echo "Create\n";
    $papi = PushAPIFactory::createHttp("localhost", 42002, "default");
    echo "Ping\n";
    $papi->ping();
    $myPart1 = new Part(array('content' => '<html><body>Hello, world</body></html>', 'directives' => array('mimeHint' => 'text/html', 'encoding' => 'utf-8')));
    $myDoc1 = new Document(array('uri' => 'http://example.com/doc.html', 'parts' => $myPart1, 'metas' => array('path' => 'Path/To/Example/1')));
    $tsukemono = "漬物";
    $tsukemonoh = "つけもの";
    $myPart2 = new Part(array('content' => '<html>' . '<head><title>Hello World</title></head>' . '<body>Hello, world' . '<br />I like eating ' . $tsukemono . ' (' . $tsukemonoh . ')!' . '</body></html>', 'directives' => array('mimeHint' => 'text/html', 'encoding' => 'utf-8')));
    $myDoc2 = new Document(array('uri' => 'http://example.com/doc2.html', 'parts' => $myPart2, 'metas' => array('path' => 'Path/To/Example/2')));
    tickSet('serialization');
    echo "Checking if document exists\n";
    $stamp = $papi->getDocumentStatus('http://example.com/doc.html');
    if ($stamp !== false) {
        echo "Yes, its stamp is " . $stamp . "\n";
    } else {
        echo "No, it does not yet exist\n";
    }
    echo "Pushing documents\n";
    $resp = $papi->addDocument(array($myDoc1, $myDoc2));
    tickSet('pushing');
    echo "Set checkpoint\n";
    $serial = $papi->setCheckpoint(0, true);
    $cp = $papi->enumerateCheckpointInfo();
    foreach ($cp as $k => $v) {
        echo "Checkpoint: name='" . $k . "' value='" . $v . "'\n";
コード例 #2
0
ファイル: test.php プロジェクト: rebe100x/YAKREP
{
    $papi->deleteDocument(getUri($mid));
}
/* The Exalead "newsburst" server address and port */
$newsburst = 'reddmz005.prod.exalead.com';
$newsburstport = 42119;
$flushTime = 60;
/* Connect to PAPI */
echo "Create\n";
if (count($argv) != 4) {
    $stderr = fopen('php://stderr', 'w');
    fwrite($stderr, "Usage: " . $argv[0] . " papi_hostname papi_port papi_source\n");
    fwrite($stderr, "Example: " . $argv[0] . " localhost 10002 default\n");
    exit;
}
$papi = PushAPIFactory::createHttp($argv[1], intval($argv[2]), $argv[3]);
echo "Ping\n";
$papi->ping();
/* Let's have some burst */
$last = time();
$serial = false;
$flushRetry = 0;
$seen = 0;
$checkpoint = intval($papi->getCheckpoint());
for ($fp = false;;) {
    /* (Re)Open a connection to newsburst */
    if ($fp === false) {
        echo "Connecting to newsburst: ";
        for ($i = 0; $i < 60; $i++) {
            $fp = @fsockopen($newsburst, $newsburstport, &$errno, &$errstr, 120);
            if ($fp !== false && is_resource($fp)) {
コード例 #3
0
ファイル: parserPAPI.php プロジェクト: rebe100x/YAKREP
$feedColl = $db->feed;
$docsPAPI = array();
$q = empty($_GET['q']) ? "all" : $_GET['q'];
$forceUpdate = empty($_GET['forceUpdate']) ? 0 : $_GET['forceUpdate'];
if ($q != '') {
    if ($q == 'all') {
        // we parse all valid feeds
        $query = array('status' => 1);
    } else {
        $query = array('name' => $q, 'status' => 1);
    }
    $res = $feedColl->find($query);
    $feeds = iterator_to_array($res);
    //var_dump($feeds);
    try {
        $papi = PushAPIFactory::createHttp("ec2-54-246-84-102.eu-west-1.compute.amazonaws.com", 62002, "parserPAPI");
        //echo "Ping\n";
        //$papi->ping();
    } catch (PushAPIFactory $e) {
        echo "Error: " . $e->getMessage() . "\n";
    }
    function mapIt($i)
    {
        $i = convert_smart_quotes($i);
        // clean rounded quotes from MSWord
        return '/' . $i . '/';
    }
    foreach ($feeds as $feed) {
        //var_dump($feed);
        $file = $feed['name'] . ".xml";
        echo 'Parsing feed : ' . $feed['name'] . '<br>';