1 | <?php |
||
9 | class FacebookPosterPost |
||
10 | { |
||
11 | /** @var string */ |
||
12 | protected $content; |
||
13 | |||
14 | /** @object FacebookPosterLink */ |
||
15 | protected $link; |
||
16 | |||
17 | /** @object FacebookPosterImage */ |
||
18 | protected $image; |
||
19 | |||
20 | /** @object FacebookPosterVideo */ |
||
21 | protected $video; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $apiEndpoint = 'me/feed'; |
||
27 | |||
28 | 4 | public function __construct($postContent) |
|
32 | |||
33 | /** |
||
34 | * Get Post content. |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | 4 | public function getContent() |
|
42 | |||
43 | /** |
||
44 | * Set facebook post main link. |
||
45 | * |
||
46 | * @param string $link |
||
47 | * |
||
48 | * @return $this |
||
49 | */ |
||
50 | 1 | public function withLink($link) |
|
56 | |||
57 | /** |
||
58 | * Set facebook post image. |
||
59 | * |
||
60 | * @param $imagePath |
||
61 | * @param string $endpoint |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | 1 | public function withImage($imagePath, $endpoint = 'me/photos') |
|
71 | |||
72 | /** |
||
73 | * Set facebook post image. |
||
74 | * |
||
75 | * @param $videoPath |
||
76 | * @param array $data |
||
77 | * @param string $endpoint |
||
78 | * |
||
79 | * @return $this |
||
80 | */ |
||
81 | 1 | public function withVideo($videoPath, $data = [], $endpoint = 'me/videos') |
|
82 | { |
||
83 | 1 | $this->video = new video($videoPath, $endpoint); |
|
84 | |||
85 | 1 | if (isset($data['title'])) { |
|
86 | 1 | $this->video->setTitle($data['title']); |
|
87 | 1 | } |
|
88 | |||
89 | 1 | if (isset($data['description'])) { |
|
90 | 1 | $this->video->setDescription($data['description']); |
|
91 | 1 | } |
|
92 | |||
93 | 1 | return $this; |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * Return Facebook Post api endpoint. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 4 | public function getApiEndpoint() |
|
105 | |||
106 | /** |
||
107 | * Build Facebook post request body. |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | 4 | public function getPostBody() |
|
131 | } |
||
132 |