heiseonline / shariff-backend-php

👮 PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.
http://ct.de/-2467514
133 stars 44 forks source link

Failed to load resource /backend/index.php #4

Closed mshandmore closed 9 years ago

mshandmore commented 9 years ago

Ich setze das WordPress-Plugin Shariff ein und auf allen Seiten, auf denen die Share Buttons dargestellt werden, erscheint in der Browser-Konsole die folgende Fehlermeldung:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) Beispiel: http://www.danielbaer.eu/wp-content/plugins/shariff-sharing/backend/index.php?url=http%3A%2F%2Fwww.danielbaer.eu%2Fkontakt%2F&ttl=30&service=gftl

Ich habe das bereits dem Entwickler gemeldet (https://wordpress.org/support/topic/error-failed-to-load-resource?replies=6), allerdings kommt das Problem auch in der originalen Backend-Datei vor. Kann das reproduziert werden?

yanniks commented 9 years ago

Hast du Zugriff auf die Konsole des Servers? Wenn ja kannst du die PHP manuell ausführen, dann gibt es auch einen detaillierteren Error-Log.

mshandmore commented 9 years ago

X-Powered-By: PHP/5.2.17 Content-type: text/html


Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /XXX/wp-content/plugins/shariff-sharing/backend/index.php on line 4

yanniks commented 9 years ago

Kannst du bitte mal den Inhalt deiner Datei Posten? Da scheint was nicht zu stimmen.

mshandmore commented 9 years ago

<?php require_once DIR.'/vendor/autoload.php';

use Heise\Shariff\Backend;

class Application { public static function run() { header('Content-type: application/json'); $services = array(); if (strpos($_GET["service"],"g") !== false) { $services[] = "GooglePlus"; } if (strpos($_GET["service"],"t") !== false) { $services[] = "Twitter"; } if (strpos($_GET["service"],"f") !== false) { $services[] = "Facebook"; } if (strpos($_GET["service"],"l") !== false) { $services[] = "LinkedIn"; } if (strpos($_GET["service"],"p") !== false) { $services[] = "Pinterest"; } $arrayconfig = Array ( "cache" => Array ( "ttl" => $_GET["ttl"]),"domain" => $_SERVER["HTTP_HOST"],"services" => $services); $shariff = new Backend($arrayconfig); echo json_encode($shariff->get($_GET["url"])); } }

Application::run();

razorness commented 9 years ago

PHP 5.2 untestützt keine Namespaces. Diese sind erst mit PHP 5.3 gekommen: http://php.net/manual/en/language.namespaces.rationale.php

Laut composer.json ist gar PHP 5.4 Vorraussetzung: https://github.com/heiseonline/shariff-backend-php/blob/master/composer.json#L22

mshandmore commented 9 years ago

Guten Morgen,

der Webserver läuft mit PHP 5.6., über die Konsole anscheinend nur 5.2.

yanniks commented 9 years ago

Das ist aber merkwürdig, wie ist der Server auf dem System installiert? Hast du das selbst gemacht?

mshandmore commented 9 years ago

Ich bin bei einem Shared-Hoster.

Ich habe mir das nun nochmal angeschaut. Der 500 Error erscheint in der Konsole nur, wenn display_errors auf OFF gesetzt ist. Wenn es auf ON gesetzt ist, erscheint der 500 Error nicht. Dafür erscheint bei Aufruf von http://www.danielbaer.eu/wp-content/plugins/shariff-sharing/backend/index.php?url=http%3A%2F%2Fwww.danielbaer.eu%2Fkontakt%2F&ttl=30&service=gftl die folgende Fehlermeldung:


Fatal error: Uncaught exception 'Zend\Cache\Exception\InvalidArgumentException' with message 'Cache directory '/tmp' not readable' in /XXX/wp-content/plugins/shariff-sharing/backend/vendor/zendframework/zend-cache/Zend/Cache/Storage/Adapter/FilesystemOptions.php:138 Stack trace:

0 /XXX/wp-content/plugins/shariff-sharing/backend/src/Backend.php(28): Zend\Cache\Storage\Adapter\FilesystemOptions->setCacheDir('/tmp')

1 /XXX/wp-content/plugins/shariff-sharing/backend/index.php(28): Heise\Shariff\Backend->__construct(Array)

2 /XXX/wp-content/plugins/shariff-sharing/backend/index.php(33): Application::run()

3 {main}

thrown in /XXX/wp-content/plugins/shariff-sharing/backend/vendor/zendframework/zend-cache/Zend/Cache/Storage/Adapter/FilesystemOptions.php on line 138

compeak commented 9 years ago

Der Fehler bedeutet, dass als Cache-Verzeichnis /tmp eingestellt ist, du daraus aber nicht lesen kannst. Versuche mal, ein Verzeichnis auf deinem Webspace anzulegen und trage es als Cache-Verzeichnis (Beispiel) in der Shariff-Konfiguration ein.