我正在将数据提交到api中,因此我得到了三个值:
{"Status":true/false,"Message":here is message,"Data":{"LeadId":lead id if data submitted}}
我已经使用Curl成功提交了线索,并且得到了结果。但是如何获取不同变量中的Status,Message和LeadId
$status=status;
$Message=message;
$LeadId=leadid;
Array ( [HTTP/1_1_200_OK Date:_Mon,_13_May_2019_09:52:38_GMT Server:_Apache/2_2_34_(Amazon) X-Powered-By:_PHP/5_3_29 Set-Cookie:_PHPSESSID] => 3smg5ubq61hoesonb5krj5lsb2; path=/ Expires: 0 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Access-Control-Allow-Credentials: true Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Auth-Token Access-Control-Allow-Origin: * Access-Control-Max-Age: 3600 Content-Length: 55 Connection: close Content-Type: application/json; charset=utf-8 {"Status":True,"Message":"Successfull","Data":{"LeadId":6113456}} )
$request=url goes here;
$post='user='.$user.'&pass='.$pass.'&camp='.$camp.' &name='.$name.'&mobile_number='.$mobile;
$session=curl_init($request);
curl_setopt($session,CURLOPT_POST,true);
curl_setopt($session,CURLOPT_POSTFIELDS,$post);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
var_dump($response);