Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.
$requests = file_get_contents($request_url);
//Print all outstanding app requests
echo '<pre>';
print_r($requests);
echo '</pre>';
print $requests->data->to->name; //not working
{"data":[{"id":"456332257759434_749673123","application":{"name":"Virtual Body Shots","namespace":"virtualbodyshots","id":"432338926835657"},"to":{"name":"Rich Ezeikiel","id":"749673123"},"from":{"name":"Kim Lee","id":"100000430620787"},"message":"Would you be interested in giving me a tequila body shot?","created_time":"2012-12-24T11:06:04+0000"},{"id":"319927994792678_749673123","application":{"name":"Virtual Body Shots","namespace":"virtualbodyshots","id":"432338926835657"},"to":{"name":"Rich Ezeikiel","id":"749673123"},"from":{"name":"Zekio Richie","id":"100004945084145"},"message":"Would you be interested in giving me a tequila body shot?","created_time":"2012-12-24T03:13:55+0000"}],"paging":{"previous":"https:\/\/graph.facebook.com\/749673123\/apprequests?access_token=432338926835657|LuUcubU7ml2mWX55yN8_ltrYe-Y&limit=50&since=1356347164&__paging_token=456332257759434_749673123&__previous=1","next":"https:\/\/graph.facebook.com\/749673123\/apprequests?access_token=432338926835657|LuUcubU7ml2mWX55yN8_ltrYe-Y&limit=50&until=1356318835&__paging_token=319927994792678_749673123"}}
Do more with
{"data":
[
{
"id":"456332257759434_749673123",
"application":
{
"name":"Virtual Body Shots",
"namespace":"virtualbodyshots",
"id":"432338926835657"
},
"to":
{
"name":"Rich Ezeikiel","id":"749673123"
},
"from":
{
"name":"Kim Lee",
"id":"100000430620787"
},
"message": "Would you be interested in giving me a tequila body shot?",
"created_time":"2012-12-24T11:06:04+0000"
},
{
"id":"319927994792678_749673123",
"application":
{
"name":"Virtual Body Shots",
"namespace":"virtualbodyshots",
"id":"432338926835657"
},
"to":
{
"name":"Rich Ezeikiel",
"id":"749673123"
},
"from":
{
"name":"Zekio Richie",
"id":"100004945084145"
},
"message":"Would you be interested in giving me a tequila body shot?",
"created_time":"2012-12-24T03:13:55+0000"
}
],
"paging":
{
"previous":"https:\/\/graph.facebook.com\/749673123\/apprequests?access_token=432338926835657|LuUcubU7ml2mWX55yN8_ltrYe-Y&limit=50&since=1356347164&__paging_token=456332257759434_749673123&__previous=1","next":"https:\/\/graph.facebook.com\/749673123\/apprequests?access_token=432338926835657|LuUcubU7ml2mWX55yN8_ltrYe-Y&limit=50&until=1356318835&__paging_token=319927994792678_749673123"
}
}
//name:
$request->data->to['name'];
//to:
$request->data->from['name'];
<?php // RAY_temp_zefex.php
error_reporting(E_ALL);
echo '<pre>';
// TEST DATA
$jso = <<<ENDJSO
{"data":[{"id":"456332257759434_749673123","application":{"name":"Virtual Body Shots","namespace":"virtualbodyshots","id":"432338926835657"},"to":{"name":"Rich Ezeikiel","id":"749673123"},"from":{"name":"Kim Lee","id":"100000430620787"},"message":"Would you be interested in giving me a tequila body shot?","created_time":"2012-12-24T11:06:04+0000"},{"id":"319927994792678_749673123","application":{"name":"Virtual Body Shots","namespace":"virtualbodyshots","id":"432338926835657"},"to":{"name":"Rich Ezeikiel","id":"749673123"},"from":{"name":"Zekio Richie","id":"100004945084145"},"message":"Would you be interested in giving me a tequila body shot?","created_time":"2012-12-24T03:13:55+0000"}],"paging":{"previous":"https:\/\/graph.facebook.com\/749673123\/apprequests?access_token=432338926835657|LuUcubU7ml2mWX55yN8_ltrYe-Y&limit=50&since=1356347164&__paging_token=456332257759434_749673123&__previous=1","next":"https:\/\/graph.facebook.com\/749673123\/apprequests?access_token=432338926835657|LuUcubU7ml2mWX55yN8_ltrYe-Y&limit=50&until=1356318835&__paging_token=319927994792678_749673123"}}
ENDJSO;
// DECODE INTO AN OBJECT
$obj = json_decode($jso);
// ACTIVATE THIS TO SEE THE ENTIRE OBJECT
// var_dump($obj);
// USE OOP NOTATION TO FIND INFORMATION IN THE OBJECT
foreach ($obj->data as $unit)
{
// ACTIVATE THIS TO SEE THE UNIT OBJECT
// var_dump($unit);
$t = (string)$unit->to->name;
$f = (string)$unit->from->name;
echo PHP_EOL . "TO: $t, FROM: $f";
}
HTH, ~Ray
Premium Content
You need an Expert Office subscription to comment.Start Free Trial