I have a problem. I need to send to android-client a json text and a lot of images but dont know how it all send via responce. Can you give some tips
app->get(’/test’, function (Request $request, Response $response) {
$array=array();
$image1=file_get_contents(“http://newdevstory.esy.es/media/images/test.png”);
$image2=file_get_contents(“http://newdevstory.esy.es/media/images/test2.png”);
$partitions=‘design’;
$array[]=R::getRow(‘SELECT title FROM titles WHERE part=?’,array($partitions));
$array[]=R::getRow(‘SELECT caption FROM captions WHERE part=?’,array($partitions));
$date=json_encode($array,JSON_UNESCAPED_UNICODE);
Since it seems you want to return JSON, I’d suggest to use the following at the end of your function:
return $response->withJson($array, 200);
The documentation specifies that in this case (sending a JSON response using withJson, you don’t have to bother setting the Content-Type header, Slim does it for you).
i need return […] and two(maybe more image) to client
Can’t you return an URL for each of these images and let your Android app deal with them ?
That way you would send JSON data, and in your JSON response you would have your images URLs.