Created
December 19, 2014 22:29
-
-
Save n00shie/6e63f7f91db4ff51d406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$toData = $datum['to']['data']; | |
$toArray = []; | |
$tagArray = []; | |
foreach ($toData as $toUser) { | |
array_push($toArray, $toUser['id']); | |
} | |
if (isset($datum['message_tags'])) { | |
foreach($datum['message_tags'] as $tag) { | |
if (array_search($tag['id'], $toArray) !== false) { | |
$toArray[$tag['id']] = null; | |
} | |
} | |
} | |
$toArray = array_filter($toArray); | |
// if $toArray is empty, then this post was a self post, e.g the poster posted on their own wall and tagged a bunch of people | |
// otherwise the post has a definite recipient | |
if(!empty($rekeyedToData)) { | |
// should never be more than one element in the array | |
if(count($rekeyedToData) > 1){ | |
Logger::log("More than one element in recipient array."); | |
} | |
$recipient = end($rekeyedToData); // could have used reset, instead of end() to get the first element. Assumption is there would only by one element in the array | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment