Thursday, May 21, 2015

Warning (2): substr() expects parameter 1 to be string, array given [CORE/src/Network/Http/Adapter/Stream.php, line 98]

What could be the reason for these errors http://i.imgur.com/oMwVBGS.png

My code is working properly on local server, after moving it to staging I got this error.

My code is as follow.

<?php

namespace App\Controller;

use Cake\Core\Configure;
use Cake\Network\Exception\NotFoundException;
use Cake\View\Exception\MissingTemplateException;
use Cake\ORM\TableRegistry;
use Cake\Network\Http\Client;
use Cake\Cache\Cache;

class WebController extends AppController
{

   
public $helpers = ['Common'];

   
public function home()
   
{
        $http            
= new Client();
        $apiBaseURL      
= Configure::read('API_BASE_URL');
        $storeId          
= Configure::read('API_STORE_ID');

       
// Read areas list
        $areas
= Cache::read('areas_list');
       
if( empty($areas) ) {
           
// Load from API and store in cache
            $response
= $http->get($apiBaseURL.'areas', [
               
'store_id' => $storeId,
           
]);

            $json
= $response->json;

           
if( isset($json['status']) && $json['status'] == 'success' ) {
               
Cache::write('areas_list', $json['data']);
           
}

            $areas
= $json['data'];
            unset
($json);
       
}

        $this
->set('areas', $areas);
   
}


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: