1. Go to this page and download the library: Download draliragab/socialize library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use DrAliRagab\Socialize\Socialize;
$fb = Socialize::facebook('page_2');
setBackdatedTime(float|Carbon $backdated_time)
setBackdatedTimeGranularity(string $backdated_time_granularity) // One of ['year', 'month', 'day', 'hour', 'minute']
addChildAttachment(string $link, string $name = null, string $description = null, string $image_hash = null, string $picture = null)
setFeedTargeting(int $age_max = null, int $age_min = null, array $college_years = null, array $education_statuses = null, array $genders = null, array $geo_locations = null, array $interests = null, int $locales = null, array $relationship_statuses = null)
setLink(string $link)
setMessage(string $text)
setMultiShareEndCard(bool $multi_share_end_card = true)
setMultiShareOptimized(bool $multi_share_optimized = true)
setObjectAttachment(string $object_attachment)
setPlace(string $placeId)
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)
attachMedia(int $mediaId)
attachMedias(array $mediaIds)
// After setting the options you can share the post
sharePost()
// Also after sharing you can add comments to the post
addComment('Awesome comment')
// And you ca delete the post
deletePost(int $postId) // returns true if the post is deleted successfully
use DrAliRagab\Socialize\Socialize;
use DrAliRagab\Socialize\Enums\OpenGraph\OgAction;
use DrAliRagab\Socialize\Enums\OpenGraph\OgObject;
$fb = Socialize::facebook();
$response = $fb
->setBackdatedTime(now()->subDays(2))
->setBackdatedTimeGranularity('day')
->addChildAttachment(
link: 'https://example.com/1',
name: "Awesome name",
description: "Awesome description",
picture: "https://example.com/image.jpg"
)
->addChildAttachment(
link: 'https://example.com/2',
name: "Awesome name 2",
description: "Awesome description 2",
picture: "https://example.com/image2.jpg"
)
->setFeedTargeting(
age_max: 65,
age_min: 18,
)
->setLink('https://example.com')
->setMessage('Awesome message')
->setMultiShareEndCard(true)
->setMultiShareOptimized(true)
->setPublished(true)
->setTargeting(
age_min: 18
)
->setAction(OgAction::FEELS, OgObject::EXCITED)
->sharePost() // Must be called after setting the options
->addComment('Awesome comment'); // Must be called after sharing the post
$postId = $response->getPostId(); // Get the post id
// Delete the post
$deleted = $fb->deletePost($postId);
$fb = Socialize::facebook();
$mediaId = $fb->uploadPhoto('https://example.com/image.jpg')->getMediaId();
// You can use the media id to attach it to a post
$postId = Socialize::facebook()
->attachMedia($mediaId)
->setMessage('Awesome image')
->sharePost()
->getPostId();
$photoId = Socialize::facebook()
->uploadPhoto('https://example.com/image.jpg', 'Awesome image', true, false)
->getMediaId(); // returns the photo id
$deleted = Socialize::facebook()->deletePhoto($photoId); // returns true if the photo is deleted successfully
$data = Socialize::facebook()-getPosts();
$twitter = Socialize::twitter();
use DrAliRagab\Socialize\Socialize;
$twitter = Socialize::twitter('account_2');
superFollowersOnly()
addPlace(string $placeId)
addPoll(array $pollOptions, int $pollDuration)
quoteTweet(string $tweetId)
restrictReply(string $restrictReply) // "mentionedUsers" and "following" are the only options
inReplyTo(string $tweetId)
addMedia(array $mediaIds)
tagUsers(array $usernames)