PHP返回JSON,获取值 [英] PHP Returning JSON, Fetch Value

查看:73
本文介绍了PHP返回JSON,获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我的一个客户电子商务网站的代码如下,我已经集成了运输API但是在集成后它给了我错误代码执行时弹出一个弹出窗口。



Hello,

I have below code for one of my clients e-commerce website and I have integrated shipping API to it but after integrating it is giving me error and a PopUp when the code is executed.

$shipment['waybill'] = '123456789'; // waybill number
            $shipment['name'] = $order_info['shipping_firstname'] . " " . $order_info['shipping_lastname']; // consignee name
            $shipment['order'] = $order_id; // client order number
            $shipment['products_desc'] = $product['name'];
            $shipment['order_date'] = date(DATE_ISO8601, strtotime($order_info['date_added'])); // ISO Format date(DATE_ISO8601, strtotime($order_info['date_added']));
            $shipment['payment_mode'] = $pay_check_bhavik;
            $shipment['total_amount'] = (double)($order_total_for_delhivery); // in INR
            $shipment['cod_amount'] = $order_total_for_delhivery; // amount to be collected, required for COD
            $shipment['add'] = $order_info['shipping_address_1'] . " " . $order_info['shipping_address_2']; // consignee address
            $shipment['city'] = $order_info['shipping_city'];
            $shipment['state'] = $order_info['shipping_zone'];
            $shipment['country'] = $order_info['shipping_country'];
            $shipment['phone'] = $order_info['telephone'];
            $shipment['pin'] = $order_info['shipping_postcode'];
            $shipment['quantity'] = $product['quantity']; // quanitity of quantity
            $shipment['seller_name']='seller'; //name of seller
            $shipment['seller_add']='add of seller'; // add of seller
            $shipment['seller_cst'] = 'cst no of seller'; //cst number of seller
            $shipment['seller_tin'] = 'tin no of seller';  //tin number of seller
            $shipment['seller_inv']= 'invoice_number'; // invoice number of shipment
            $shipment['seller_inv_date']= '2013-04-08T18:30:00+00:00'; // ISO Format
            // pickup location information //
            $pickup_location['add'] = '113 Barthal, Dundahera';
            $pickup_location['city'] = 'New Delhi';
            $pickup_location['country'] ='India';
            $pickup_location['name'] = 'CLIENT WAREHOUSE';  // Use client warehouse name
            $pickup_location['phone'] = '011-23456245';
            $pickup_location['pin'] = '110070';
            $pickup_location['state'] = 'Delhi';
            $shipments = array($shipment);
            $package_data['shipments'] = $shipments;
            $package_data['pickup_location'] = $pickup_location;
            $params['format'] = 'json';
            $params['data'] =json_encode($package_data);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($params));
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
            $result_shipping_delhivery = curl_exec($ch);

            //print_r($params['data']);
            //print_r($result);
            curl_close($ch);





现在我没有得到错误发起的地方以及我从API获取JSON的变量。错误是SyntaxError:Unexpected token {



Now I am not getting where the error is initiating and in which variable I am getting the JSON from the API. Error is "SyntaxError: Unexpected token{"

推荐答案

货运[' waybill'] = ' 123456789'; // 运单号
shipment['waybill'] = '123456789'; // waybill number


货件[' name'] =


order_info [' shipping_firstname']。
order_info['shipping_firstname'] . " " .


这篇关于PHP返回JSON,获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆