{"id":18916795,"url":"https://github.com/dusterio/link-preview","last_synced_at":"2025-04-04T11:12:43.936Z","repository":{"id":5780007,"uuid":"51131602","full_name":"dusterio/link-preview","owner":"dusterio","description":"Link preview generator for PHP with Laravel support","archived":false,"fork":false,"pushed_at":"2024-03-01T13:32:53.000Z","size":98,"stargazers_count":124,"open_issues_count":16,"forks_count":59,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T10:06:17.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/dusterio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-02-05T07:05:46.000Z","updated_at":"2025-03-26T06:46:01.000Z","dependencies_parsed_at":"2024-06-18T13:43:04.349Z","dependency_job_id":"cb038b21-df35-4bab-a8cc-db05aa724c6a","html_url":"https://github.com/dusterio/link-preview","commit_stats":{"total_commits":70,"total_committers":10,"mean_commits":7.0,"dds":0.4571428571428572,"last_synced_commit":"0be2d5e98540ec97fac2ca8fa39bed18fb6b6d01"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusterio%2Flink-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusterio%2Flink-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusterio%2Flink-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusterio%2Flink-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dusterio","download_url":"https://codeload.github.com/dusterio/link-preview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166168,"owners_count":20894654,"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":[],"created_at":"2024-11-08T10:22:01.439Z","updated_at":"2025-04-04T11:12:43.902Z","avatar_url":"https://github.com/dusterio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Link Preview \n[![Build Status](https://travis-ci.org/dusterio/link-preview.svg)](https://travis-ci.org/dusterio/link-preview)\n[![Code Climate](https://codeclimate.com/github/dusterio/link-preview/badges/gpa.svg)](https://codeclimate.com/github/dusterio/link-preview/badges)\n[![Test Coverage](https://codeclimate.com/github/dusterio/link-preview/badges/coverage.svg)](https://codeclimate.com/github/dusterio/link-preview/badges)\n[![Total Downloads](https://poser.pugx.org/dusterio/link-preview/d/total.svg)](https://packagist.org/packages/dusterio/link-preview)\n[![Latest Stable Version](https://poser.pugx.org/dusterio/link-preview/v/stable.svg)](https://packagist.org/packages/dusterio/link-preview)\n[![Latest Unstable Version](https://poser.pugx.org/dusterio/link-preview/v/unstable.svg)](https://packagist.org/packages/dusterio/link-preview)\n[![License](https://poser.pugx.org/dusterio/link-preview/license.svg)](https://packagist.org/packages/dusterio/link-preview)\n\nA PHP class that consumes an HTTP(S) link and returns an array of preview information. Think of Facebook sharing -\nwhenever you paste a link, it goes to specified page and fetches some details.\n\nInitially based on [kasp3r/link-preview](https://github.com/kasp3r/link-preview) that seems to be abandoned.\n\nIncludes integrations with: Laravel 5\n\n## Dependencies\n\n* PHP \u003e= 5.5\n* Guzzle \u003e= 6.1\n* Symfony DomCrawler \u003e= 3.0\n\n## Installation via Composer\n\nTo install simply run:\n\n```\ncomposer require dusterio/link-preview\n```\n\nOr add it to `composer.json` manually:\n\n```json\n{\n    \"require\": {\n        \"dusterio/link-preview\": \"~1.2\"\n    }\n}\n```\n\n## Direct usage\n\n```php\nuse Dusterio\\LinkPreview\\Client;\n\n$previewClient = new Client('https://www.boogiecall.com/en/Melbourne');\n\n// Get previews from all available parsers\n$previews = $previewClient-\u003egetPreviews();\n\n// Get a preview from specific parser\n$preview = $previewClient-\u003egetPreview('general');\n\n// Convert output to array\n$preview = $preview-\u003etoArray();\n```\n\n**Output**\n\n```\narray(4) {\n  [\"cover\"]=\u003e\n  string(94) \"https://cdn.boogiecall.com/media/images/872398e3d9598c494a2bed72268bf018_1440575488_7314_s.jpg\"\n  [\"images\"]=\u003e\n  array(8) {\n    [0]=\u003e\n    string(94) \"https://cdn.boogiecall.com/media/images/872398e3d9598c494a2bed72268bf018_1440575488_7314_s.jpg\"\n    [1]=\u003e\n    string(94) \"https://cdn.boogiecall.com/media/images/b18970cd4c808f4dcdf7c319779ab9c6_1457347623_2419_s.jpg\"\n  }\n  [\"title\"]=\u003e\n  string(44) \"Events, parties \u0026 live concerts in Melbourne\"\n  [\"description\"]=\u003e\n  string(107) \"List of events in Melbourne. Nightlife, best parties and concerts in Melbourne, event listings and reviews.\"\n}\n```\n\n## Timeouts and errors\n\n```php\n// Default connect timeout is 5 seconds, you can change it to anything you want\n$previewClient-\u003egetParser('general')-\u003egetReader()-\u003econfig(['connect_timeout' =\u003e 3.14]);\n\n// Default maximum redirect count is 10, but you can change it too\n$previewClient-\u003egetParser('general')-\u003egetReader()-\u003econfig(['allow_redirects' =\u003e ['max' =\u003e 10]]);\n\n// If there is a network error (DNS, connect, etc), we throw ConnectionErrorException\ntry {\n    $previews = $previewClient-\u003egetPreviews();\n} catch (\\Dusterio\\LinkPreview\\Exceptions\\ConnectionErrorException $e) {\n    echo \"Oh no!\";\n}\n```\n\n### YouTube example\n\n```php\nuse Dusterio\\LinkPreview\\Client;\n\n$previewClient = new LinkPreview('https://www.youtube.com/watch?v=v1uKhwN6FtA');\n\n// Only parse YouTube specific information\n$preview = $previewClient-\u003egetPreview('youtube');\n\nvar_dump($preview-\u003etoArray());\n```\n\n**Output**\n\n```\narray(2) {\n  [\"embed\"]=\u003e\n  string(128) \"\u003ciframe id=\"ytplayer\" type=\"text/html\" width=\"640\" height=\"390\" src=\"http://www.youtube.com/embed/v1uKhwN6FtA\" frameborder=\"0\"/\u003e\"\n  [\"id\"]=\u003e\n  string(11) \"v1uKhwN6FtA\"\n}\n```\n\n### Usage in Laravel 5\n\n```php\n// Add in your config/app.php\n\n'providers' =\u003e [\n    '...',\n    'Dusterio\\LinkPreview\\Integrations\\LaravelServiceProvider',\n];\n\n'aliases' =\u003e [\n    '...',\n    'Preview'    =\u003e 'Dusterio\\LinkPreview\\Integrations\\LaravelFacade',\n];\n\n// Set target url\nPreview::setUrl('https://www.boogiecall.com');\n\n// Get parsed HTML tags as a plain array\nPreview::getPreview('general')-\u003etoArray();\n\n// In case of redirects, see what the final url was\necho Preview::getUrl();\n```\n\n## Todo\n\n1. Add more unit and integration tests\n2. Update documentation\n3. Add more parsers\n\n## License\n\nThe MIT License (MIT)\nCopyright (c) 2016 Denis Mysenko\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdusterio%2Flink-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdusterio%2Flink-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdusterio%2Flink-preview/lists"}