{"id":22774349,"url":"https://github.com/yr72dpi/socialmeta","last_synced_at":"2025-08-09T20:08:45.337Z","repository":{"id":171558935,"uuid":"469696111","full_name":"YR72dpi/SocialMeta","owner":"YR72dpi","description":"¤ The SocialMeta class is a PHP utility for generating social media meta tags. These meta tags are used to provide information about a webpage when it is shared on social media platforms like Google+, Facebook, and Twitter. ","archived":false,"fork":false,"pushed_at":"2023-08-02T21:27:14.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T13:11:29.541Z","etag":null,"topics":["facebook","google","opengraph","seo","social-media","social-network","twitter"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YR72dpi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-14T11:05:11.000Z","updated_at":"2023-08-02T21:27:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"456ce47a-b7ee-4b1c-82a7-c8b58fb756df","html_url":"https://github.com/YR72dpi/SocialMeta","commit_stats":null,"previous_names":["yr72dpi/socialmeta"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/YR72dpi/SocialMeta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FSocialMeta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FSocialMeta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FSocialMeta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FSocialMeta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YR72dpi","download_url":"https://codeload.github.com/YR72dpi/SocialMeta/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FSocialMeta/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262883640,"owners_count":23379231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facebook","google","opengraph","seo","social-media","social-network","twitter"],"created_at":"2024-12-11T18:14:21.260Z","updated_at":"2025-07-01T02:33:17.636Z","avatar_url":"https://github.com/YR72dpi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"*thanks to chatGPT for documentation*\n# SocialMeta Class Documentation\n\n## Description\n\nThe `SocialMeta` class is a PHP utility for generating social media meta tags. These meta tags are used to provide information about a webpage when it is shared on social media platforms like Google+, Facebook, and Twitter. The class allows you to set various meta parameters, such as URL, title, description, and images, which are then used to generate the appropriate meta tags.\n\n## Class Properties\n\n- `private $fileParam`: A private variable to store the configuration parameters loaded from the `socialMeta_param.json` file.\n- `const PARAM_FILE`: A constant representing the filename of the configuration file (`socialMeta_param.json`).\n- `const IMG_FOLDER`: A constant representing the folder path for storing images used in social media meta tags.\n- `private $commonParam`: An associative array containing common meta parameters like URL, title, and description.\n- `private $SocialImages`: An associative array to store the URLs or file paths of the social media images for Google+, Facebook, and Twitter.\n- `private $othersParams`: An associative array to store additional parameters like `og_type` (Open Graph type) and `twitter_card` (Twitter card type).\n\n## Class Methods\n\n### Private Methods\n\n#### `private function remote_file_exists($url)`\n\n- Description: Checks if a remote file exists using the `allow_url_fopen` setting and `file_exists` function.\n- Parameters:\n  - `$url` (string): The URL of the remote file to check.\n- Returns:\n  - `true` if the remote file exists.\n  - `false` if the remote file does not exist or cannot be accessed.\n\n#### `private function fileFind($url)`\n\n- Description: Determines whether the given URL is a remote file or a local file and checks if the file exists.\n- Parameters:\n  - `$url` (string): The URL or file path to check.\n- Returns:\n  - The URL or file path if it exists.\n  - `false` if the URL or file path does not exist.\n\n### Public Methods\n\n#### `public static function install()`\n\n- Description: Installs the configuration file `socialMeta_param.json` if it does not exist.\n- Parameters: None\n- Returns: None\n- Throws: Throws any caught exception.\n\n#### `public function __construct(string $url, string $title, string $description)`\n\n- Description: Class constructor used to initialize the `SocialMeta` object with the common meta parameters (`$url`, `$title`, and `$description`) and loads the configuration from the `socialMeta_param.json` file.\n- Parameters:\n  - `$url` (string): The URL of the webpage.\n  - `$title` (string): The title of the webpage.\n  - `$description` (string): The description of the webpage.\n- Returns: None\n- Throws:\n  - Throws an exception if the `socialMeta_param.json` file is not installed or if the images folder parent is not set or does not exist, or if the default image is not set or does not exist.\n\n#### `public function setGoogleImg(string $url)`\n\n- Description: Sets the Google+ image URL or file path.\n- Parameters:\n  - `$url` (string): The URL or file path of the image to be used for Google+.\n- Returns:\n  - `true` if the image is set successfully.\n- Throws: Throws an exception if no image is found.\n\n#### `public function setOgImg(string $url)`\n\n- Description: Sets the Open Graph (Facebook) image URL or file path.\n- Parameters:\n  - `$url` (string): The URL or file path of the image to be used for Open Graph (Facebook).\n- Returns:\n  - `true` if the image is set successfully.\n- Throws: Throws an exception if no image is found.\n\n#### `public function setTwitterImg(string $url)`\n\n- Description: Sets the Twitter image URL or file path.\n- Parameters:\n  - `$url` (string): The URL or file path of the image to be used for Twitter.\n- Returns:\n  - `true` if the image is set successfully.\n- Throws: Throws an exception if no image is found.\n\n#### `public function setSameImg(string $url)`\n\n- Description: Sets the same image for Google+, Open Graph (Facebook), and Twitter.\n- Parameters:\n  - `$url` (string): The URL or file path of the image to be used for all three platforms.\n- Returns:\n  - `true` if the image is set successfully.\n- Throws: Throws an exception if no image is found.\n\n#### `public function setOgType(string $type)`\n\n- Description: Sets the Open Graph type.\n- Parameters:\n  - `$type` (string): The Open Graph type to set (e.g., \"website\", \"article\", etc.).\n- Returns:\n  - `true` if the Open Graph type is set successfully.\n  - `false` if the provided type is empty.\n- Note: This function allows an empty type, which may not be desirable, as it will set the type to an empty value.\n\n#### `public function setTwitterCard(string $card)`\n\n- Description: Sets the Twitter card type.\n- Parameters:\n  - `$card` (string): The Twitter card type to set (e.g., \"summary\", \"summary_large_image\", etc.).\n- Returns:\n  - `true` if the Twitter card type is set successfully.\n  - `false` if the provided card is empty.\n- Note: This function allows an empty card type, which may not be desirable, as it will set the card type to an empty value.\n\n#### `public function print()`\n\n- Description: Prints the generated social media meta tags based on the provided meta parameters and images.\n- Parameters: None\n- Returns: None\n\n## How to Use\n\n1. Install the `socialMeta_param.json` file by calling the `SocialMeta::install()` method.\n2. Set the images folder parent path and the default image URL or file path in the `socialMeta_param.json` file.\n3. Create a new `SocialMeta` object by passing the URL, title, and description of the webpage to the constructor.\n4. Optionally, set the images and other parameters using the provided setter methods.\n5. Call the `print()` method to generate and print the social media meta tags for Google+, Facebook, and Twitter.\n\n## Example\n\n```php\n// Assuming the `SocialMeta_param.json` file is already installed and configured properly.\n\n// Create a new SocialMeta object with common meta parameters\n$meta = new SocialMeta(\"https://example.com\", \"Example Page\", \"This is an example page.\");\n\n// Set different images for Google+, Facebook, and Twitter\n$meta-\u003esetGoogleImg(\"https://example.com/images/google_img.jpg\");\n$meta-\u003esetOgImg(\"https://example.com/images/facebook_img.jpg\");\n$meta-\u003esetTwitterImg(\"https://example.com/images/twitter_img.jpg\");\n\n// Set the same image for all platforms\n$meta-\u003esetSameImg(\"https://example.com/images/common_img.jpg\");\n\n// Optionally, set other parameters\n$meta-\u003esetOgType(\"article\");\n$meta-\u003esetTwitterCard(\"summary_large_image\");\n\n// Generate and print the social media meta tags\n$meta-\u003eprint();\n```\n\nPlease note that this documentation is based on the provided code and may not cover all possible use cases\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyr72dpi%2Fsocialmeta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyr72dpi%2Fsocialmeta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyr72dpi%2Fsocialmeta/lists"}