我有问题如何从文件获取内容网络获取特定值“clickUrl”,我正在使用file_get_contents函数
<?php
$json_url = "someone.web.id";
$json = file_get_contents($json_url);
$json=str_replace('},]',"}]",$json);
$data = json_decode($json);
echo "<pre>";
print_r($data);
echo "</pre>";
?>
,结果是
stdClass Object
(
[serialId] => 110153837
[productId] => 212065382
[os] => Linux
[validResponse] => 1
[errorMessage] =>
[adsDetails] => Array
(
[0] => stdClass Object
(
[requestTimestamp] => 1429665317403
[adId] => SAP_272131
[clickUrl] => http://adtrack.king.com/modules/adTracking/adClicked.jsp?type=ad&st1=startapp&st2=33&st3=us&st4=CCSS_Launchgameplay_PlayNow_480x320_EN&st5=&st6=gmbffR8bQ6WClgZBzdIdIQ&st7=212065382&linkId=3302
[trackingClickUrl] => http://www.startappexchange.com/tracking/adClick?d=IAAAAAAgAAA6X15KS0ZCDQlZD0hIFUUDX0BSEUVIVlFLT11EX1tfCAEdQUUFQEVCQk1UQFBRSEhJWFtcUlNPRkdQRUBRQ1NQU1BDSUJCWUxZVgNaS0lSR1dQQE1UX1NDTENMWlhNWlREQUVTQkJUQ0hXTVJARBsdBwhNXVREQ1dQQUkyMSA6W1VCTUFXXlpTRldXQ1dQRkkyMSA6XFRASENFSl5bVjcwMDw%2BJjE5JFNUWF4BEB4TBQpNWlJEQldQS0kCHx1LHwoLGF4aEA4DHg5aQURcFREPFQIMDUBASE0BBwQABBIXUEZTT0VRU0JSU1BcSEdXW1dTIisqJzUtPldSQE0wPUBBSE0mICwmNDE8KyBCQUZcOT4kPjMtOzE6Jyo8SFZOTh4SHRpCQ0hYXE1GV0lXWlZTPyQ7PzE1UUBRTT0ACgoHFFAZCBsbGQwNCldVQUkHERwWC0BGTU1HSltbVlVaR0JcIjksPDMEGkBGTk01PDshSFFBTkNSRlpTSUNXX1NCTklASltXVl1LRUIFFEMFXUEDXwFfTUMVXEJWWVxLXkBRREBQExQBXFIWS1NBWVIvJSErPD0lUUFTTTckIyYtOCI3KCsrSFBKTjMgPzE%2BMzE2OyI%2BWkVAVCstSFBPTkRPQldUR01VQFNRTEhJDF5eX0ZMSkkHExgSFVNTXl5BWkZHVFxNXVBEIDAqUUJXTTgKHRcbFxcRG08nBREcARoABh0OHhEJTi8bFBkADAtNXVJEQ1pQRENWRkZXW1tDS0BBWllWSFJJThcOH1oKGR4CQAATFxQNCh0bGA0KHBAAARUGEVNSX143DxUGEAAADkZOQUkHExgSFVNSXV4XFy8hOkxZX1hMUENZT0BZQFNSV15KSUBXUVlTLywqMjYtNzBCSEVYCAIeChVXUVhTW0tIRUNWREJTRUhUXFNHSkZMSldWVkhIXURCSk1cXUFLXkBLSk0aHAMCSA%3D%3D&lu=http%3A%2F%2Fadtrack.king.com%2Fmodules%2FadTracking%2FadClicked.jsp%3Ftype%3Dad%26st1%3Dstartapp%26st2%3D33%26st3%3Dus%26st4%3DCCSS_Launchgameplay_PlayNow_480x320_EN%26st5%3D%26st6%3DgmbffR8bQ6WClgZBzdIdIQ%26st7%3D212065382%26linkId%3D3302
[trackingUrl] => http://www.trackimpression.com/tracking/adImpression?d=IAAAAAAgAAA6X15KS0ZCDQlZD0hIFUUDX0BSEUVIVlFLT11EX1tfCAEdQUUFQEVCQk1UQFBRSEhJWFtcUlNPRkdQRUBRQ1NQU1BDSUJCWUxZVgNaS0lSR1dQQE1UX1NDTENMWlhNWlREQUVTQkJUQ0hXTVJARBsdBwhNXVREQ1dQQUkyMSA6W1VCTUFXXlpTRldXQ1dQRkkyMSA6XFRASENFSl5bVjcwMDw%2BJjE5JFNUWF4BEB4TBQpNWlJEQldQS0kCHx1LHwoLGF4aEA4DHg5aQURcFREPFQIMDUBASE0BBwQABBIXUEZTT0VRU0JSU1BcSEdXW1dTIisqJzUtPldSQE0wPUBBSE0mICwmNDE8KyBCQUZcOT4kPjMtOzE6Jyo8SFZOTh4SHRpCQ0hYXE1GV0lXWlZTPyQ7PzE1UUBRTT0ACgoHFFAZCBsbGQwNCldVQUkHERwWC0BGTU1HSltbVlVaR0JcIjksPDMEGkBGTk01PDshSFFBTkNSRlpTSUNXX1NCTklASltXVl1LRUIFFEMFXUEDXwFfTUMVXEJWWVxLXkBRREBQExQBXFIWS1NBWVIvJSErPD0lUUFTTTckIyYtOCI3KCsrSFBKTjMgPzE%2BMzE2OyI%2BWkVAVCstSFBPTkRPQldUR01VQFNRTEhJDF5eX0ZMSkkHExgSFVNTXl5BWkZHVFxNXVBEIDAqUUJXTTgKHRcbFxcRG08nBREcARoABh0OHhEJTi8bFBkADAtNXVJEQ1pQRENWRkZXW1tDS0BBWllWSFJJThcOH1oKGR4CQAATFxQNCh0bGA0KHBAAARUGEVNSX143DxUGEAAADkZOQUkHExgSFVNSXV4XFy8hOkxZX1hMUENZT0BZQFNSV15KSUBXUVlTLywqMjYtNzBCSEVYCAIeChVXUVhTW0tIRUNWREJTRUhUXFNHSkZMSldWVkhIXURCSk1cXUFLXkBLSk0aHAMCSA%3D%3D
[externalTrackingUrl] =>
[title] => Candy Crush Soda Saga
[description] => Download Candy Crush Soda Saga for free now. It’s Sodalicious!Candy Crush Soda Saga is a brand new game from the makers of the legendary Candy Crush Saga. New candies, more divine combinations and challenging game modes brimming with purple soda!Candy Crush Soda Saga is completely free to play, ...
[imageUrl] => http://lh3.ggpht.com/Igs-DxhnnCi8FfJB4N9LA_rJ0rIYsr553reCLa0Yr3KucEGfUMfzAxu4Co3j-dKrTKI=w100
[urlScheme] =>
-----------------------------------------------------------------------
我如何获得价值[clickUrl]?感谢
答案 0 :(得分:1)
尝试:
foreach($data->adsDetails as $detail) {
echo $detail->clickUrl;
}