1 | <?php |
||
10 | class FacebookPosterPost |
||
11 | { |
||
12 | /** @var string */ |
||
13 | protected $content; |
||
14 | |||
15 | /** @object FacebookPosterLink */ |
||
16 | protected $link; |
||
17 | |||
18 | /** @object FacebookPosterImage */ |
||
19 | protected $image; |
||
20 | |||
21 | /** @object FacebookPosterVideo */ |
||
22 | protected $video; |
||
23 | |||
24 | /** @var array */ |
||
25 | protected $params; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $apiEndpoint = 'me/feed'; |
||
31 | |||
32 | 7 | public function __construct($postContent) |
|
36 | |||
37 | /** |
||
38 | * Get Post content. |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | 7 | public function getContent() |
|
46 | |||
47 | /** |
||
48 | * Set facebook post main link. |
||
49 | * |
||
50 | * @param string $link |
||
51 | * |
||
52 | * @return $this |
||
53 | */ |
||
54 | 1 | public function withLink($link) |
|
55 | { |
||
56 | 1 | $this->link = new Link($link); |
|
57 | |||
58 | 1 | return $this; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * Set facebook post image. |
||
63 | * |
||
64 | * @param $imagePath |
||
65 | * @param string $endpoint |
||
66 | * |
||
67 | * @return $this |
||
68 | */ |
||
69 | 1 | public function withImage($imagePath, $endpoint = 'me/photos') |
|
70 | { |
||
71 | 1 | $this->image = new Image($imagePath, $endpoint); |
|
72 | |||
73 | 1 | return $this; |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * Set facebook post image. |
||
78 | * |
||
79 | * @param $videoPath |
||
80 | * @param array $data |
||
81 | * @param string $endpoint |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | 1 | public function withVideo($videoPath, $data = [], $endpoint = 'me/videos') |
|
86 | { |
||
87 | 1 | $this->video = new video($videoPath, $endpoint); |
|
88 | |||
89 | 1 | if (isset($data['title'])) { |
|
90 | 1 | $this->video->setTitle($data['title']); |
|
91 | } |
||
92 | |||
93 | 1 | if (isset($data['description'])) { |
|
94 | 1 | $this->video->setDescription($data['description']); |
|
95 | } |
||
96 | |||
97 | 1 | return $this; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Schedule the post for a date in the future. |
||
102 | * |
||
103 | * @param string $timestamp UNIX timestamp |
||
104 | * |
||
105 | * @param \DateTimeInterface|int $timestamp |
||
106 | * @return $this |
||
107 | */ |
||
108 | 3 | public function scheduledFor($timestamp) |
|
119 | |||
120 | /** |
||
121 | * Return Facebook Post api endpoint. |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 4 | public function getApiEndpoint() |
|
129 | |||
130 | /** |
||
131 | * Build Facebook post request body. |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 7 | public function getPostBody() |
|
159 | } |
||
160 |