मेरे पास LuraCast Restler API के साथ एक REST वेब सेवा है। यह अब तक ठीक काम कर रहा है। अचानक सेवा में मेरे अनुरोध के जवाब में मुझे JSON डेटा नहीं मिल रहा है।
X-Debug हमेशा सेवा के लिए प्रत्येक अनुरोध के साथ निम्नलिखित नोटिस लौटाता है।
( ! ) Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php on line 1136
Call Stack
# Time Memory Function Location
1 0.0013 631072 {main}( ) ../restIndex.php:0
2 0.0969 1170720 Restler->addAPIClass( ) ../restIndex.php:14
3 0.0971 1181912 Restler->generateMap( ) ../restler.php:248
4 0.0971 1184616 parse_doc( ) ../restler.php:652
5 0.0971 1184984 DocParser->parse( ) ../restler.php:1157
6 0.0972 1205520 DocParser->parseLines( ) ../restler.php:1073
7 0.0972 1209704 DocParser->parseLine( ) ../restler.php:1079
8 0.0973 1209944 DocParser->setParam( ) ../restler.php:1111
9 0.0973 1209944 DocParser->formatClass( ) ../restler.php:1120
( ! ) Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php on line 1136
Call Stack
# Time Memory Function Location
1 0.0013 631072 {main}( ) ../restIndex.php:0
2 0.1065 1224952 Restler->addAuthenticationClass( ) ../restIndex.php:15
3 0.1065 1225304 Restler->addAPIClass( ) ../restler.php:260
4 0.1068 1228176 Restler->generateMap( ) ../restler.php:248
5 0.1068 1229568 parse_doc( ) ../restler.php:652
6 0.1068 1229936 DocParser->parse( ) ../restler.php:1157
7 0.1068 1239456 DocParser->parseLines( ) ../restler.php:1073
8 0.1068 1241448 DocParser->parseLine( ) ../restler.php:1079
9 0.1069 1241696 DocParser->setParam( ) ../restler.php:1111
10 0.1069 1241696 DocParser->formatClass( ) ../restler.php:1120
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php:1136) in /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php on line 385
Call Stack
# Time Memory Function Location
1 0.0013 631072 {main}( ) ../restIndex.php:0
2 0.1102 1228048 Restler->handle( ) ../restIndex.php:16
3 0.1233 1461248 Restler->sendData( ) ../restler.php:366
4 0.2814 1547080 header ( ) ../restler.php:385
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php:1136) in /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php on line 386
Call Stack
# Time Memory Function Location
1 0.0013 631072 {main}( ) ../restIndex.php:0
2 0.1102 1228048 Restler->handle( ) ../restIndex.php:16
3 0.1233 1461248 Restler->sendData( ) ../restler.php:366
4 0.2835 1547048 header ( ) ../restler.php:386
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php:1136) in /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php on line 387
Call Stack
# Time Memory Function Location
1 0.0013 631072 {main}( ) ../restIndex.php:0
2 0.1102 1228048 Restler->handle( ) ../restIndex.php:16
3 0.1233 1461248 Restler->sendData( ) ../restler.php:366
4 0.2846 1547064 header ( ) ../restler.php:387
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php:1136) in /Applications/MAMP/htdocs/aem.davidcasillas.es/public/webservice/restler/restler.php on line 388
Call Stack
# Time Memory Function Location
1 0.0013 631072 {main}( ) ../restIndex.php:0
2 0.1102 1228048 Restler->handle( ) ../restIndex.php:16
3 0.1233 1461248 Restler->sendData( ) ../restler.php:366
4 0.2914 1547072 header ( ) ../restler.php:388
अंत में डेटा प्रतिक्रिया में भेजा जाता है, लेकिन JSON प्रारूप में नहीं, इसलिए मेरा Movil ऐप इसे और संसाधित नहीं कर सकता है।
जैसा कि मैंने कहा है कि सेवा अब तक ठीक काम कर रही है। मुझे पता नहीं है कि क्या यह नोटिस त्रुटि से संबंधित है, लेकिन वे स्पष्ट रूप से प्रतीत होते हैं।
क्या आप किसी भी दिशा में इंगित कर सकते हैं कि मैं इस समस्या को कैसे मिटा सकता हूं?
अगर यह यहाँ किसी भी मदद का हो सकता है मेरा कोड है:
यह मेरी अनुक्रमणिका स्क्रिप्ट है जहां मैं रेस्टलर कॉन्फ़िगर करता हूं:
<?php
require_once "../../BaseDatos.php";
require_once "restler/restler.php";
#set autoloader
#do not use spl_autoload_register with out parameter
#it will disable the autoloading of formats
spl_autoload_register("spl_autoload");
$r = new Restler();
$r->setSupportedFormats("JsonFormat");
$r->addAPIClass("Rest");
$r->addAuthenticationClass("Seguridad");
$r->handle();
और यह सार्वजनिक एपीआई वर्ग है (मैं सिर्फ एक विधि दिखाता हूं)
class Rest
{
/**
* @brief Una instancia de la clase BaseDatos
*
* @var BaseDatos $db
*/
private $db;
/**
* brief Constructor de la clase.
*
* Inicializa una instancia de la clase BaseDatos.
*
*/
function __construct() {
$this->db = BaseDatos::getInstance();
}
public function getFuentes($nombreUsuario, $password) {
$fuentes = $this->db->getFuentes();
$fuentes = array("fuentes" => $fuentes);
return $fuentes;
}
और यह BaseDatos श्रेणी की विधि है, जो दी जाने वाली जानकारी को पुनः प्राप्त करती है:
public function getFuentes() {
//SELECT * FROM fuentes
$queryString = "SELECT * FROM " . TABLA_FUENTES . " ORDER BY nombreFuente";
$queryResult = $this->query($queryString);
if ($this->errno != 0) {
//ERRRO. mysql
$this->setErrorNoAndMessage(ErrorCode::ERROR_MYSQL, $this->error);
return FALSE;
}
$resultado = array();
while ($row = $queryResult->fetch_assoc() ) {
$resultado[] = $row;
}
$this->resetErrorNoAndMessage();
return $resultado;
}
उत्तर:
उत्तर № 1 के लिए 1समस्या मेरे डॉक्टर की टिप्पणियों से संबंधित थी जिसे मैंने हाल ही में जोड़ा है। @class
क्लास डॉक्यूमेंटेशन में मैंने जो टैग जोड़ा है, वह एक विरोध पैदा कर रहा था, हो सकता है कि रेसलर के डॉकपारर इस विशिष्ट टैग को नहीं संभालते।
मेरे प्रश्न में शामिल किए गए पहले 2 नोटिस तब हुए जब डॉकपारर ने इसे निष्पादित करने का प्रयास किया formatClass()
प्रतिक्रिया में विधि शायद @class
टैग और नहीं Class
PHP में घोषणा।
हो सकता है कि इस एपीआई की गहरी समझ वाला कोई व्यक्ति कुछ प्रकाश जोड़ सकता है।
केवल डॉक्स से इस टैग को हटाने और सब कुछ फिर से काम कर रहा है।