if ($this->verb == ActivityVerb::POST && count($this->objects) == 1) {
$activity['object'] = $this->objects[0]->asArray();
+ // Context stuff. For now I'm just sticking most of it
+ // in a property called "context"
+
+ if (!empty($this->context)) {
+
+ if (!empty($this->context->location)) {
+ $loc = $this->context->location;
+
+ // GeoJSON
+
+ $activity['geopoint'] = array(
+ 'type' => 'Point',
+ 'coordinates' => array($loc->lat, $loc->lon)
+ );
+
+ }
+
+ $activity['to'] = $this->context->getToArray();
+ $activity['context'] = $this->context->asArray();
+ }
+
// Instead of adding enclosures as an extension to JSON
// Activities, it seems like we should be using the
// attachedObjects property of ActivityObject
}
}
-
- // Context stuff. For now I'm just sticking most of it
- // in a property called "context"
-
- if (!empty($this->context)) {
-
- if (!empty($this->context->location)) {
- $loc = $this->context->location;
-
- // GeoJSON
-
- $activity['geopoint'] = array(
- 'type' => 'Point',
- 'coordinates' => array($loc->lat, $loc->lon)
- );
-
- }
-
- $activity['to'] = $this->context->getToArray();
- $activity['context'] = $this->context->asArray();
- }
-
return array_filter($activity);
}
*
* @return array the context
*/
+
function asArray()
{
$context = array();
- $context['replyToId'] = $this->replyToID;
- $context['replyToUrl'] = $this->replyToUrl;
+ $context['replyTo'] = $this->getInReplyToArray();
$context['conversation'] = $this->conversation;
$context['forwardId'] = $this->forwardID;
$context['forwardUrl'] = $this->forwardUrl;
- // XXX: We might want to have the attention to stuff
- // in here like we do with Atom
-
return array_filter($context);
}
*
* @return array the array of recipients
*/
+
function getToArray()
{
$tos = array();
foreach ($this->attention as $attnUrl) {
- $to = array('id' => $attnUrl, 'url' => $attnUrl);
+ $to = array(
+ 'objectType' => 'person',
+ 'id' => $attnUrl,
+ 'url' => $attnUrl
+ );
$tos[] = $to;
}
return $tos;
}
+ /*
+ * Show replyTo
+ */
+
+ function getInReplyToArray()
+ {
+ $replyToObj = array('objectType' => 'note');
+
+ $replyToObj['id'] = $this->replyToID;
+
+ if (!empty($this->replyToUrl)) {
+ $replyToObj['url'] = $this->replyToUrl;
+ }
+
+ }
+
}
+