Guys如何从卷曲响应中删除不需要的数据,例如双双引号和字符串(126),我只需要Url,而我正在获得此卷曲响应:
string(126)“ http://www.mydomainxyz.co/router/offers/74938e12xxxxxf519d57bd63252d/pre_entry?sdk=false&uid=805xxxx03&ai_id=15xx719261”
我只需要普通网址,请帮助我已经尝试了很多事情,但是下面没有好的结果代码:
<?php
$url_send ="https://www.mydomainxyz.co/supply_api/surveys/offer?";
function sendPostData($url, $post){
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_USERAGENT,'Content-type: application/json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "api_token=eca8c17xxxxxxxxx486ec8a7271&user_identifier=80xxxxxx9203");
$jsonStr = curl_exec($ch);
curl_close($ch);
$json = json_decode($jsonStr, true);
var_dump($json['offer_url']);
}
echo " " . sendPostData($url_send, $str_data);
?>
答案 0 :(得分:0)
在您的功能sendPostData()
中,您使用
var_dump($json['offer_url']);
问题出在哪里。您实际上只需要返回该值,该值将在最后的回显中打印出来。因此,将var_dump()
更改为...
return $json['offer_url'];