Skip to content

Commit 981b501

Browse files
committed
Update readme.md
1 parent 5daef90 commit 981b501

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

README.md

+35-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# php-activitystreams
22

3+
> A PHP implementation of the Activity Streams 2.0 specification
4+
35
[![Software License][ico-license]](LICENSE.md)
46

5-
** This package is in active development, this is not a complete implementation of ActivityStreams 2.0 **
7+
**This package is in active development, this is not a complete implementation of ActivityStreams 2.0**
68

7-
An activitystreams 2.0 php package.
9+
A modern AS2 php library. At the moment, only the [object model type](https://www.w3.org/TR/activitystreams-core/#object) is partially implemented. I look forward to getting this feature complete by the end of summer 2017.
810

911
## Install
1012

@@ -15,19 +17,43 @@ $ composer require dansup/php-activitystreams
1517
```
1618

1719
## Usage
20+
> Lets create a [basic object model](https://www.w3.org/TR/activitystreams-core/#object) and echo the response to a json encoded string.
21+
1822
``` php
1923
use Dansup\ActivityStreams\ServerFactory;
2024

21-
$server = ServerFactory::create(['version' => '2.0']);
22-
23-
$item = $server->object();
25+
$item = ServerFactory::create('object');
2426

25-
$item->setType('Note')
26-
$item->setId('http://example.org/note/123');
27-
$item->setName('Our Weather Is Fine');
28-
$item->setContent('I feel that the weather is appropriate to our season and location.');
27+
$item->type('Note')
28+
$item->id('http://example.org/note/123');
29+
$item->name('Our Weather Is Fine');
30+
$item->content('I feel that the weather is appropriate to our season and location.');
31+
$item->attributedTo([
32+
'id' => 'http://joe.website.example/',
33+
'type' => 'Person',
34+
'name' => 'Joe Smith'
35+
]);
36+
$item->addField('url', 'http://example.org/permalink/123');
2937

3038
echo $item->get();
39+
40+
```
41+
42+
``` json
43+
{
44+
"@context": "https:\/\/www.w3.org\/ns\/activitystreams",
45+
"type": "Note",
46+
"id": "http:\/\/example.org\/note\/123",
47+
"name": "Our Weather Is Fine",
48+
"attributedTo": {
49+
"id": "http:\/\/joe.website.example\/",
50+
"type": "Person",
51+
"name": "Joe Smith"
52+
},
53+
"content": "I feel that the weather is appropriate to our season and location.",
54+
"published": "2017-04-21T01:31:20+00:00",
55+
"url": "http:\/\/example.org\/permalink\/123"
56+
}
3157
```
3258

3359

0 commit comments

Comments
 (0)