Hello,
i try to create a script php to communicate with the API's flarum.
for make this : https://discuss.flarum.org/d/2808-how-i-implemented-cross-authentication-with-flarum
I have no error message, but the page is always searching a response indefinitely...
i work on a local with MAMP.
Here my code to test, i just ask list of users :
header('Content-Type: text/plain');
$name = 'forum.griphus.dev';
//la requête
$envoi = "GET /api/users HTTP/1.1\r\n";
$envoi .= "Host: forum.griphus.dev\r\n";
$envoi .= "Connection: Close\r\n";
/*ouverture socket*/
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if($socket < 0){
die('FATAL ERROR: socket_create() : " '.socket_strerror($socket).' "');
}
if (socket_connect($socket,gethostbyname($name),80) < 0){
die('FATAL ERROR: socket_connect()');
}
/*/ouverture socket*/
/*envoi demande*/
if(($int = socket_write($socket, $envoi, strlen($envoi))) === false){
die('FATAL ERROR: socket_write() failed, '.$int.' characters written');
}
/*/envoi demande*/
/*lecture réponse*/
$reception = '';
while($buff = socket_read($socket, 2000)){
$reception.=$buff;
}
echo $reception;
/*/lecture réponse*/
socket_close($socket);
EDIT : the problem come from "socket_read()" who load infinitly, but i don't know why.