rvkvino Posted May 22, 2015 Share Posted May 22, 2015 I need to return the json format of data for client request. I used prestashop 1.6 and enabled the web services and created the authkey. I'm using the PSWebServiceLibrary.php to get the data from webservice and process the result, my code like below <?phpdefine('DEBUG', true); // Debug modedefine('PS_SHOP_PATH', 'http://www.example.com'); // Root path of your PrestaShop storedefine('PS_WS_AUTH_KEY', 'myauthkey'); // Auth key (Get it in your Back Office)require_once('PSWebServiceLibrary.php');try{$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);// Here we set the option array for the Webservice : we want customers resources$opt['resource'] = 'categories';$opt['output_format'] = 'JSON';$opt['ps_method'] = 'GET';// Call$output = $webService->get($opt);echo $output; // And also i have tried echo json_encode($output); It will display result with http header and response body contents //If i use print_r($output->categories->children()); It will display array with xml contents and http header and response body contents }catch (PrestaShopWebserviceException $e){// Here we are dealing with errors$trace = $e->getTrace();if ($trace[0]['args'][0] == 404) echo 'Bad ID';else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';else echo 'Other error';}?> This code return the output with HTTP Header and HTTP response body contents. I don't need to display the extra string except my result. How to do it using this web service. Link to comment Share on other sites More sharing options...
darknessgc Posted August 23, 2015 Share Posted August 23, 2015 Hi, If you following this : http://flowcoding.com/prestashop-webservice-json Sure you can do what U want. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now