Ebay.php 1.83 KB
Newer Older
1
2
3
4
<?php

namespace app\Models\parserSkripte;
use App\Models\Searchengine;
5
6
use DateTimeZone;
use DateTime;
7
8
9
10
11
12
13
14
15
16

class Ebay extends Searchengine 
{
	public $results = [];

	function __construct (\SimpleXMLElement $engine,  \App\MetaGer $metager)
	{
		parent::__construct($engine, $metager);
	}

17
	public function loadResults ($result)
18
19
20
21
22
23
24
25
26
27
28
	{
		try {
			$content = simplexml_load_string($result);
		} catch (\Exception $e) {
			abort(500, "$result is not a valid xml string");
		}
		
		if(!$content)
		{
			return;
		}
29
30
31
		$results = $content;
		
		$results = $results->{"searchResult"};
32
		$count = 0;
33
		foreach($results->{"item"} as $result)
34
35
		{
			$title = $result->{"title"}->__toString();
36
			$link = $result->{"viewItemURL"}->__toString();
37
			$anzeigeLink = $link;
38
39
40
41
42
43
44
45
46
47
48
			$time = $result->{"listingInfo"}->{"endTime"}->__toString();
			$time = date(DATE_RFC2822, strtotime($time));
			$price = intval($result->{"sellingStatus"}->{"convertedCurrentPrice"}->__toString()) * 100;
			$descr = "<p>Preis: " . $result->{"sellingStatus"}->{"convertedCurrentPrice"}->__toString() . " €</p>";
			$descr .= "<p>Versandkosten: " . $result->{"shippingInfo"}->{"shippingServiceCost"}->__toString() . " €</p>";
			if( isset($result->{"listingInfo"}->{"listingType"}))
				$descr .= "<p>Auktionsart: " . $result->{"listingInfo"}->{"listingType"}->__toString() . "</p>";
			$descr .= "<p>Auktionsende: " . $time . "</p>";
			if( isset($result->{"primaryCategory"}->{"categoryName"}))
				$descr .= "<p class=\"text-muted\">Kategorie: " . $result->{"primaryCategory"}->{"categoryName"}->__toString() . "</p>";
			$image = $result->{"galleryURL"}->__toString();
49
50
51
52
53
54
55
56
			$this->counter++;
			$this->results[] = new \App\Models\Result(
				$this->engine,
				$title,
				$link,
				$anzeigeLink,
				$descr,
				$this->gefVon,
57
58
				$this->counter,
				false,
59
60
				$image,
				$price
61
62
63
64
65
66
67
			);
			$count++;

		}
		
	}
}