jeudi 31 mai 2018

htmlspecialchars() expects parameter 1 to be string, array given - Laravel

These are my controllers

public static function getAccessToken()
{

    $url = 'http://api.tech/oauth/authenticate';
    $query = [
        'grant_type' => 'client_credentials',
        'client_id' => 'E3PuC',
        'client_secret' => 'IhvkpkvMdAL7gqpL',
        'scope' => 'bookings.read,images.create,images.read,images.update,locations.read,rates.read,rates.update,reports.read,reviews.read,rooms.create,rooms.delete,properties.read',
    ];

    $client = new Client();

    $response = $client->get($url, ['query' => $query]);

    $content = json_decode($response->getBody()->getContents());

    if ($content) {

        return $content->access_token;
    } else {
        return null;
    }
}
 public function getReviews()
{
    $client = new Client();
    $access_token = $this->getAccessToken();
    $url = 'http://api.tech/hotels/88244/reviews';
    $query = [
        'access_token' => $access_token,
    ];

    $response = $client->get($url, ['query' => $query]);

    $content = json_decode($response->getBody()->getContents());

    if ($content->status == 'success') {

        // return $content->access_token;
       return $content->data;
    //    return $response;
    } else {
        return null;
    }

}
 public function index()
{
    $content = $this->getReviews();
     return view('channel.channel', [
        'content' => $content
    ]);
}

When i try to output the content in my blade as a link, it says ---

htmlspecialchars() expects parameter 1 to be string, array given

and this is my blade file

<a href="">This</a>

It also throws an error when i try to output it like thus



Please How can i solve the error



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire