0
我是API和JSON的noob,希望對以下任何幫助。我正在使用PHP Linkedin Library來運行People Queries。JSON數組值到變量(Linkedin PHP庫)
下面是相關代碼:
<?php
$OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON);
$keywords = (isset($_GET['keywords'])) ? $_GET['keywords'] : "Marketing";
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>#peopleSearch" method="get">
Search by Keywords: <input type="text" value="<?php echo $keywords?>" name="keywords" /><input type="submit" value="Search" />
</form>
<?php
$query = '?sort=distance¤t-company=true&keywords='.$keywords;
$response = $OBJ_linkedin->searchPeople($query);
if($response['success'] === TRUE) {
echo "<pre>" . print_r($response['linkedin'], TRUE) . "</pre>";
} else {
// request failed
echo "Error retrieving people search results:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>";
}
} else {
// user isn't connected
?>
下面是輸出的摘錄,我得到
{"people": {
"_count": 10,
"_start": 0,
"_total": 11,
"values": [
{
"firstName": "Peter",
"headline": "Frontend Engineer at Lot18",
"id": "kYZ3B2hHYH",
"lastName": "Welch",
"pictureUrl": "http://m.c.lnkd.licdn.com/mpr/mprx/0_e0hbvSXvhiSoTO2PERiqvfLV850d342PoOq4vakwx8IJOyR1XJrwRmr5mIx9C0DxWpGMsWVjBZEQ",
"relationToViewer": {"distance": 3}
},
]
}}
我想拍攝像「名字」和「pictureUrl」到變量的字段我可以在別處使用。例如。
<img src="<?php echo $picture-url; ?>" />
我該怎麼做呢?我花了數天的時間尋找/試圖弄清楚這一點,仍然沒有運氣。任何幫助深表感謝!
我在上面的「if」語句中放置了該代碼,但我沒有得到任何結果。這裏是[pastebin](http://pastebin.com/Fdkjvjtm)'if($ response ['success'] === TRUE){ // echo「
」; $ responseObject = json_decode($ response ['linkedin']); echo $ responseObject-> values [0] - > pictureUrl; }' – ace973