Skip to content

Commit

Permalink
Refactor: Facebook Provider
Browse files Browse the repository at this point in the history
Improve Enums
  • Loading branch information
DrAliRagab committed Dec 29, 2022
1 parent 17fbcc3 commit b579e20
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can share posts to **Facebook**, **Twitter**, **Instagram** and more is comi
$fb = Socialize::facebook()
->setMessage('Awesome message')
->setLink('https://github.com/')
->setAction(ogAction::FEELS, ogObject::EXCITED)
->setAction(OgAction::FEELS, OgObject::EXCITED)
->sharePost();

dump($fb->getPostId()); // 123456789101112
Expand Down Expand Up @@ -198,7 +198,7 @@ setPublished(bool $published = true)
setScheduledPublishTime(int|Carbon $scheduled_publish_time)
setTags(array $tagsIds)
setTargeting(int $age_min = null, array $geo_locations = null)
setAction(ogAction $action, ogObject $object, ?ogIcon $icon = null)
setAction(OgAction $action, OgObject $object, ?OgIcon $icon = null)
attachMedia(int $mediaId)
attachMedias(array $mediaIds)

Expand All @@ -216,8 +216,8 @@ Example:

```php
use DrAliRagab\Socialize\Socialize;
use DrAliRagab\Socialize\Enums\ogAction;
use DrAliRagab\Socialize\Enums\ogObject;
use DrAliRagab\Socialize\Enums\OpenGraph\OgAction;
use DrAliRagab\Socialize\Enums\OpenGraph\OgObject;

$fb = Socialize::facebook();
$response = $fb
Expand Down Expand Up @@ -247,7 +247,7 @@ $response = $fb
->setTargeting(
age_min: 18
)
->setAction(ogAction::FEELS, ogObject::EXCITED)
->setAction(OgAction::FEELS, OgObject::EXCITED)
->sharePost() // Must be called after setting the options
->addComment('Awesome comment'); // Must be called after sharing the post

Expand Down
4 changes: 2 additions & 2 deletions src/Enums/ogAction.php → src/Enums/OpenGraph/OgAction.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace DrAliRagab\Socialize\Enums;
namespace DrAliRagab\Socialize\Enums\OpenGraph;

enum ogAction: int
enum OgAction: int
{
case AGREES = 1267092843327003;
case ATTENDS = 668012816568345;
Expand Down
4 changes: 2 additions & 2 deletions src/Enums/ogIcon.php → src/Enums/OpenGraph/OgIcon.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace DrAliRagab\Socialize\Enums;
namespace DrAliRagab\Socialize\Enums\OpenGraph;

enum ogIcon: int
enum OgIcon: int
{
case AGREE = 1402739093121224;
case ATTENDING = 395780397279063;
Expand Down
4 changes: 2 additions & 2 deletions src/Enums/ogObject.php → src/Enums/OpenGraph/OgObject.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace DrAliRagab\Socialize\Enums;
namespace DrAliRagab\Socialize\Enums\OpenGraph;

enum ogObject: int
enum OgObject: int
{
case ACCOMPLISHED = 136050896551329;
case ADVENTUROUS = 224113357712800;
Expand Down
8 changes: 4 additions & 4 deletions src/Providers/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DrAliRagab\Socialize\Providers;

use Carbon\Carbon;
use DrAliRagab\Socialize\Enums\ogAction;
use DrAliRagab\Socialize\Enums\ogIcon;
use DrAliRagab\Socialize\Enums\ogObject;
use DrAliRagab\Socialize\Enums\OpenGraph\OgAction;
use DrAliRagab\Socialize\Enums\OpenGraph\OgIcon;
use DrAliRagab\Socialize\Enums\OpenGraph\OgObject;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http;

Expand Down Expand Up @@ -438,7 +438,7 @@ public function setTargeting(int $age_min = null, array $geo_locations = null):
/**
* Add a feeling or activity and an icon to a page post. og_action_type_id and og_object_id are required when posting a feeling or activity. og_icon_id is optional however if not used an icon will be automatically supplied based on the og_object_id.
*/
public function setAction(ogAction $action, ogObject $object, ?ogIcon $icon = null): self
public function setAction(OgAction $action, OgObject $object, ?OgIcon $icon = null): self
{
$this->postData['og_action_type_id'] = $action->value;
$this->postData['og_object_id'] = $object->value;
Expand Down

0 comments on commit b579e20

Please sign in to comment.