| @@ 59-77 (lines=19) @@ | ||
| 56 | /** |
|
| 57 | * {@inheritdoc} |
|
| 58 | */ |
|
| 59 | public function publish(Message $message): bool |
|
| 60 | { |
|
| 61 | if (!$this->canPublish($message)) { |
|
| 62 | throw new MessageNotIntendedForPublisher(SocialNetwork::FACEBOOK); |
|
| 63 | } |
|
| 64 | ||
| 65 | try { |
|
| 66 | $publishPostEndpoint = '/' . $this->pageId. '/feed'; |
|
| 67 | $response = $this->facebook->post( |
|
| 68 | $publishPostEndpoint, |
|
| 69 | $this->prepareParams($message) |
|
| 70 | ); |
|
| 71 | $post = $response->getGraphNode(); |
|
| 72 | ||
| 73 | return isset($post['id']) ? !empty($post['id']) : false; |
|
| 74 | } catch (Throwable $t) { |
|
| 75 | throw new FailureWhenPublishingMessage($t); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @param Message $message |
|
| @@ 61-76 (lines=16) @@ | ||
| 58 | /** |
|
| 59 | * {@inheritdoc} |
|
| 60 | */ |
|
| 61 | public function publish(Message $message): bool |
|
| 62 | { |
|
| 63 | if (!$this->canPublish($message)) { |
|
| 64 | throw new MessageNotIntendedForPublisher(SocialNetwork::LINKEDIN); |
|
| 65 | } |
|
| 66 | ||
| 67 | try { |
|
| 68 | $publishShareEndpoint = 'v1/companies/' . $this->companyPageId. '/shares'; |
|
| 69 | $options = ['json' => $this->prepareShare($message)]; |
|
| 70 | $share = $this->linkedIn->post($publishShareEndpoint, $options); |
|
| 71 | ||
| 72 | return isset($share['updateKey']) ? !empty($share['updateKey']) : false; |
|
| 73 | } catch (Throwable $t) { |
|
| 74 | throw new FailureWhenPublishingMessage($t); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * @param Message $message |
|