{"id":13563894,"url":"https://github.com/shweshi/OpenGraph","last_synced_at":"2025-04-03T20:32:09.047Z","repository":{"id":28430286,"uuid":"116995669","full_name":"shweshi/OpenGraph","owner":"shweshi","description":"A Laravel package to fetch Open Graph data of a website.","archived":false,"fork":false,"pushed_at":"2024-04-26T03:43:41.000Z","size":142,"stargazers_count":149,"open_issues_count":5,"forks_count":28,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-26T08:00:44.324Z","etag":null,"topics":["hacktoberfest","laravel","laravel-opengraph","laravel-package","metadata","metadata-extraction","opengraph","opengraph-data","opengraph-tags"],"latest_commit_sha":null,"homepage":"https://opengraph.shashi.dev","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shweshi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2018-01-10T18:32:40.000Z","updated_at":"2024-06-07T09:12:31.980Z","dependencies_parsed_at":"2023-12-05T08:26:00.641Z","dependency_job_id":"f466fb05-49cb-4f98-9ac3-f2225d3c9e6c","html_url":"https://github.com/shweshi/OpenGraph","commit_stats":{"total_commits":122,"total_committers":16,"mean_commits":7.625,"dds":0.4508196721311475,"last_synced_commit":"61dbf19887e7fa56928ccfeaae1f31ef0c2c5f8f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shweshi%2FOpenGraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shweshi%2FOpenGraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shweshi%2FOpenGraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shweshi%2FOpenGraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shweshi","download_url":"https://codeload.github.com/shweshi/OpenGraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223030763,"owners_count":17076497,"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":["hacktoberfest","laravel","laravel-opengraph","laravel-package","metadata","metadata-extraction","opengraph","opengraph-data","opengraph-tags"],"created_at":"2024-08-01T13:01:24.328Z","updated_at":"2024-11-04T16:31:28.592Z","avatar_url":"https://github.com/shweshi.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/shashi"],"categories":["PHP"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://shweshi.github.io/OpenGraph/\"\u003e\n    \u003cimg alt=\"Laravel OpenGraph\" src=\"https://user-images.githubusercontent.com/35127382/56821996-695df500-686d-11e9-9c59-c70d0c78c80e.png\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e\u003ca href=\"https://opengraph.shashi.dev/\"\u003eOpenGraph\u003c/a\u003e is a laravel package to fetch Open Graph metadata of a website/link.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://packagist.org/packages/shweshi/OpenGraph\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/v/shweshi/OpenGraph.svg?style=flat-square\" alt=\"Latest Version on Packagist\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://packagist.org/packages/shweshi/OpenGraph\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/dt/shweshi/OpenGraph.svg?style=flat-square\" alt=\"Total Downloads\"\u003e\n  \u003c/a\u003e\n\n   \u003ca href=\"https://scrutinizer-ci.com/g/shweshi/OpenGraph/?branch=master\"\u003e\n      \u003cimg src=\"https://scrutinizer-ci.com/g/shweshi/OpenGraph/badges/quality-score.png?b=master\" alt=\"Scrutinizer Code Quality\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://styleci.io/repos/116995669\"\u003e\n      \u003cimg src=\"https://styleci.io/repos/116995669/shield?branch=master\" alt=\"StyleCI\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://www.codefactor.io/repository/github/shweshi/opengraph\"\u003e\n    \u003cimg src=\"https://www.codefactor.io/repository/github/shweshi/opengraph/badge\" alt=\"CodeFactor\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://scrutinizer-ci.com/g/shweshi/OpenGraph/build-status/master\"\u003e\n    \u003cimg src=\"https://scrutinizer-ci.com/g/shweshi/OpenGraph/badges/build.png?b=master\" alt=\"Build Status\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://app.fossa.io/projects/git%2Bgithub.com%2Fshweshi%2FOpenGraph?ref=badge_shield\"\u003e\n    \u003cimg src=\"https://app.fossa.io/api/projects/git%2Bgithub.com%2Fshweshi%2FOpenGraph.svg?type=shield\" alt=\"FOSSA Status\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n- **Easily fetch metadata of a URL.** Laravel OpenGraph fetches all the metadata of a URL.\n\n- **Supports language-specific metadata.** Laravel OpenGraph can fetch metadata in a specific language if webpage supports.\n\n- **Supports twitter metadata.** Laravel OpenGraph supports twitter OG data too.\n\n- **Verify image URL.** Laravel OpenGraph verifies that the image URL in the image metadata is valid or not.\n\n## Demo\n\n```\n  curl https://laravelopengraph.herokuapp.com/api/fetch?url=ogp.me\u0026allMeta=true\u0026language=en_GB\n```\n\n## How to use Laravel OpenGraph\n\nAn article can be found on the medium blog: https://hackernoon.com/how-to-fetch-open-graph-metadata-in-laravel-2d5d674904d7\n\n### Documentation\nhttps://opengraph.shashi.dev\n\n### Installation\n\nPerform the following operations in order to use this package\n\n- Install via composer\n\n```\ncomposer require \"shweshi/opengraph\"\n```\n\nIf you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php:\n\n- **Add Service Provider**\n  Open `config/app.php` and add `shweshi\\OpenGraph\\Providers\\OpenGraphProvider::class,` to the end of `providers` array:\n\n  ```\n  'providers' =\u003e array(\n      ....\n      shweshi\\OpenGraph\\Providers\\OpenGraphProvider::class,\n  ),\n  ```\n\n  Next under the `aliases` array:\n\n  ```\n  'aliases' =\u003e array(\n      ....\n      'OpenGraph' =\u003e shweshi\\OpenGraph\\Facades\\OpenGraphFacade::class\n  ),\n  ```\n\nIf you do run the package on Laravel 5.5+, package auto-discovery takes care of the magic of adding the service provider.\n\n### Requirements\n\n- You need to install the [DOM](http://www.php.net/en/dom) extension.\n\n### How to use\n\n- After following the above steps,\n\n  ```\n  use OpenGraph;\n\n  $data = OpenGraph::fetch(\"https://unsplash.com/\");\n  ```\n\n  this will give you an array like this...\n\n  ```\n    array (\n      'title' =\u003e 'Beautiful Free Images \u0026 Pictures | Unsplash',\n      'description' =\u003e 'Beautiful, free images and photos that you can download and use for any project. Better than any royalty free or stock photos.',\n      'type' =\u003e 'website',\n      'url' =\u003e 'https://unsplash.com/',\n      'image' =\u003e 'http://images.unsplash.com/photo-1542841791-1925b02a2bbb?ixlib=rb-0.3.5\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjEyMDd9\u0026s=aceabe8a2fd1a273da24e68c21768de0',\n      'image:secure_url' =\u003e 'https://images.unsplash.com/photo-1542841791-1925b02a2bbb?ixlib=rb-0.3.5\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjEyMDd9\u0026s=aceabe8a2fd1a273da24e68c21768de0',\n    )\n  ```\n\n  You can also pass an optional parameter either true or false along with URL. When set false it will only fetch basic metadata and in case of true it will fetch all the other optional metadata as well like audio, video, music and twitter metatags as well.\n\n  ```\n  $data = OpenGraph::fetch(\"https://unsplash.com/\", true);\n  ```\n\n  this will give you an array like this...\n\n  ```\n    array (\n      'charset' =\u003e 'UTF8',\n      'viewport' =\u003e 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui',\n      'mobile-web-app-capable' =\u003e 'yes',\n      'apple-mobile-web-app-capable' =\u003e 'yes',\n      'apple-mobile-web-app-title' =\u003e 'Unsplash',\n      'application-name' =\u003e 'Unsplash',\n      'author' =\u003e 'Unsplash',\n      'msapplication-config' =\u003e 'browserconfig.xml',\n      'msapplication-TileColor' =\u003e '#ffffff',\n      'msapplication-TileImage' =\u003e 'https://unsplash.com/mstile-144x144.png',\n      'theme-color' =\u003e '#ffffff',\n      'description' =\u003e 'Beautiful, free images and photos that you can download and use for any project. Better than any royalty free or stock photos.',\n      'twitter:site' =\u003e '@unsplash',\n      'twitter:title' =\u003e 'Beautiful Free Images \u0026 Pictures | Unsplash',\n      'twitter:description' =\u003e 'Beautiful, free images and photos that you can download and use for any project. Better than any royalty free or stock photos.',\n      'twitter:url' =\u003e 'https://unsplash.com/',\n      'twitter:card' =\u003e 'summary_large_image',\n      'twitter:image' =\u003e 'https://images.unsplash.com/photo-1546486610-e9fe4f1e6751?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjEyMDd9',\n      'title' =\u003e 'Beautiful Free Images \u0026 Pictures | Unsplash',\n      'type' =\u003e 'website',\n      'url' =\u003e 'https://unsplash.com/',\n      'image' =\u003e 'http://images.unsplash.com/photo-1546486610-e9fe4f1e6751?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjEyMDd9',\n      'image:secure_url' =\u003e 'https://images.unsplash.com/photo-1546486610-e9fe4f1e6751?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjEyMDd9',\n  )\n  ```\n\n  To fetch the metadata in a specific language you can pass the language as the third argument, this value will be used as the Accept-Language header.\n\n  ```\n  $url = \"https://ogp.me\",\n  $allMeta = true, // can be false\n  $language = 'en' // en-US,en;q=0.8,en-GB;q=0.6,es;q=0.4\n  $data = OpenGraph::fetch($url, $allMeta, $language);\n  ```\n  You can also pass additional Libxml parameters as the fourth argument ($options)  https://www.php.net/manual/en/libxml.constants.php. Default options are set to suppress the reporting of errors and warnings \n  ```\n  $data = OpenGraph::fetch($url, $allMeta, $language, $options);  \n  ```\n  You can use the fifth parameter to set the user-agent ($userAgent) of the request. The default is 'Curl'.\n  ```\n  $data = OpenGraph::fetch($url, $allMeta, $language, $options, $userAgent);  \n  ```\n \n### NOTE:\nAnyone having problems getting metadata from social media sites please use the following user agent set on this example:\n```\n$opg_array = OpenGraph::fetch('URL', true, null, null, 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)');  \n```\n\n### Exception Handling\n\nThe fetch() method, returns a FetchException with aditional data at failure.\n\n  ```\n      try {\n          $data = OpenGraph::fetch($url, true);\n      } catch (shweshi\\OpenGraph\\Exceptions\\FetchException $e) {\n          $message = $e-\u003egetMessage();\n          $data = $e-\u003egetData();\n      }\n  ```\n\n### Testing\n\n    composer test\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n### Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n### License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fshweshi%2FOpenGraph.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fshweshi%2FOpenGraph?ref=badge_large)\n\n### Support\n\u003ca href=\"https://www.buymeacoffee.com/shashi\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\n### Happy coding!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshweshi%2FOpenGraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshweshi%2FOpenGraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshweshi%2FOpenGraph/lists"}