I am able to print_r data from yahoo API in foreach loop. However, I am not able to return it in the last line of the function.
function callcontact_yahoo($consumer_key, $consumer_secret, $guid, $access_token, $access_token_secret, $usePost=false, $passOAuthInHeader=true)
{
$retarr = array(); // return value
$response = array();
$yahoo_array = array();
$newList = "";
// extract successful response
if (! empty($response))
{
list($info, $header, $body) = $response;
if ($body)
{
$yahoo_array = json_decode($body);
echo "<pre/>";
foreach($yahoo_array as $key=>$values)
{
foreach($values->contact as $keys=>$values_sub)
{
$fields = $values_sub->fields;
foreach($values_sub->fields as $field)
{
$convers = $field->value;
}
$oneemail = $convers.",";
//print_r($oneemail);
//echo "</br>";
echo "I am one email: $oneemail </br>";
}
}
}
}
return $retarr;
}
In the line of echo "I am one email: $oneemail </br>";
, there is where I can see all my email contact is listed. But how to return it as in return $retarr;
Please help. I have tried to debug it but still not got the idea.
you put it like this :
foreach($values->contact as $keys=>$values_sub)
{
$fields = $values_sub->fields;
foreach($values_sub->fields as $field)
{
$convers = $field->value;
}
$oneemail = $convers.",";
//print_r($oneemail);
//echo "</br>";
echo "I am one email: $oneemail </br>";
$retarr[] = $oneemail;
}