PHP返回JSON,获取值

编程入门 行业动态 更新时间:2024-10-24 14:16:30
本文介绍了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,获取值

本文发布于:2023-10-29 08:18:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PHP   JSON

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!