I'm a noob at APIs and JSON that would appreciate any help on the following. I'm using the PHP Linkedin Library to run People Queries.
Here's the relevant code:
<?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
?>
Here's an excerpt of the output I get
{"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}
},
]
}}
I'd like to capture the fields like "firstname" and "pictureUrl" into variables that I can use elsewhere. E.g.
<img src="<?php echo $picture-url; ?>" />
How would I go about doing that? I've spent days searching/trying to figure this out and still no luck. Any help is much appreciated!