Giter Club home page Giter Club logo

opengraph's Introduction

Hi there👋 I'm Shashi

I am an experienced Software Engineer with a passion for creating value in the form of functional, reliable and sustainable products.

I am interested in service mesh, microservice architecture, open source software, clean code, algorithms and data structures.

Currently

  • Building Service Mesh solution.
  • Learning IaC, DevOps and Cloud Engineering.
  • Writing bunch of Terraform, Python and Node.js code.

My Stats

Connect With Me

Misc

Support

I build open source projects in my free time. If you have used or liked my work, please consider buying me a coffee.

Buy Me A Coffee

opengraph's People

Contributors

alinmiron avatar anilkumarthakur60 avatar codacy-badger avatar daniel-mendes avatar fossabot avatar gavinclive avatar huulbaek avatar igor-bel avatar itsskynet avatar jurgenbosch avatar sandermenke avatar scrutinizer-auto-fixer avatar shweshi avatar stylecibot avatar usameavci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

opengraph's Issues

Support for CURL proxy

Suggestion: I think, it will be a great addition if you add support for CURL requests through proxy, passed as parameter to fetch()

Reason: Sometimes, URL access is blocked or is slow from the server's country/location. In that case it's easier to setup/use a proxy server instead of creating a custom php solution from scratch.

Problem to get meta image

Good Morning,

I'm writing you because I have had a bug when obtaining the openGraph of a url, it does not get the image because it has escaped characters and it is not validated.

When using openGraph there are certain urls from which the image is not obtained correctly, and it is because a decode of the image should be added in the verify_image_url function.

Page example:
https://www.forbes.com/sites/forbescoachescouncil/2017/04/19/networking-or-job-boards-nine-strategies-to-find-your-next-role/

Image url:
https://thumbor.forbes.com/thumbor/fit-in/1200x0/filters%3Aformat%28jpg%29/https%3A%2F%2Fblogs-images.forbes.com%2Fforbescoachescouncil%2Ffiles%2F2017%2F04%2FNetworking-or-Job-Boards-Nine-Strategies-To-Land-Your-Next-Role.jpg

Solution:
$url = urldecode ($url);

Thanks in advance,

Mirian

Add support for Laravel 11

First thank you for this package! it helps me a lot. I tried upgrading my Laravel project to 11 (from 10), but it seems this package is not compatible with the new Laravel.
When I try running composer update I get following:

Problem 1
- shweshi/opengraph V1.1.3 requires illuminate/log ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0 -> satisfiable by illuminate/log[v5.0.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16, v10.0.0, ..., v10.48.1].
- shweshi/opengraph[V1.1.1, ..., V1.1.2] require illuminate/log ^5.0|^6.0|^7.0|^8.0|^9.0 -> satisfiable by illuminate/log[v5.0.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16].
- shweshi/opengraph V1.1.0 requires illuminate/log ^5.0|^6.0|^7.0|^8.0 -> satisfiable by illuminate/log[v5.0.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27].
- Only one of these can be installed: illuminate/log[v5.0.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16, v10.0.0, ..., v10.48.1], laravel/framework[v11.0.0]. laravel/framework replaces illuminate/log and thus cannot coexist with it.
- illuminate/log[v5.6.0, ..., v5.8.36] require php ^7.1.3 -> your php version (8.3.3) does not satisfy that requirement.
- illuminate/log[v6.0.0, ..., v6.19.1] require php ^7.2 -> your php version (8.3.3) does not satisfy that requirement.
- illuminate/log[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.3.3) does not satisfy that requirement.
- illuminate/log[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.3.3) does not satisfy that requirement.
- Root composer.json requires laravel/framework ^11.0 -> satisfiable by laravel/framework[v11.0.0].
- Root composer.json requires shweshi/opengraph ^1.1 -> satisfiable by shweshi/opengraph[V1.1.0, V1.1.1, V1.1.2, V1.1.3].

It would be amazing if this was possible.

throwing an exception when the url returns 404 -breaking test.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
Run a test from cli that calls...
$data = OpenGraph::fetch($url, true); // where url returns a 404 error.
See error: shweshi\OpenGraph\Exceptions\FetchException. The requested URL returned error: 404 Not Found

Expected behavior
I would have expected the error to have been failed gracefully, returning the 404 message to the calling method.

Desktop (please complete the following information):

  • OS: MacOS with Docker/Laradock
  • Browser n/a
  • Version current/latest

Additional context
I'm actually calling it with... but still not getting past the fetch error thrown.

try {
            $data = OpenGraph::fetch($url, true);
        } catch (shweshi\OpenGraph\Exceptions\FetchException $e) {
            $message = $e->getMessage();
            $data = $e->getData();
        }

Verify image url in image attribute.

Is your feature request related to a problem? Please describe.
Image url of some of the weblinks may be broken.

Describe the solution you'd like
Verify the image url and if valid only then return in the image attribute.

include Title tag too?

Although not technically a meta tag, the title tag would be a handy addition as it is an arbitraty informative label too.

With a tiny addition between the $metadata decleration the $tags as $tag loop to create a$metadata['title'] key val pair, one could add the given title too.

        if($allMeta){
            $title = $doc->getElementsByTagName('title');
            $metadata['title'] = $title->length > 0 ? $title->item(0)->textContent : null ;
        }

By putting it here, should there be a metata tag called title too, it would override this value for the preffered one.

Unable to retrieve og data for FB posts

Hi Team,
Before I speak about the issue, I would first like to say that the package does a very good job on almost all urls. Great job !

To speak about the issue I am facing, am having troubles only with retrieving og data for FB posts url. The result appears empty.
However this is not the case when I use this package with twiiter urls, blogs, instagram urls.
So I am here to seek some help in case am missing something in the way am accessing it.

TIA

Twitter post images not generating inside image tag due to verify_image_url function

Describe the bug
verify_image_url Function is assuming twitter post images with ":orig", ":large" ":medium" or ":small" as invalid images and thus is sending empty image value on the fetch return array.

Generated example:

Array
(
    [0] => Array
        (
            [robots] => NOODP
            [msapplication-TileImage] => //abs.twimg.com/favicons/win8-tile-144.png
            [msapplication-TileColor] => #00aced
            [facebook-domain-verification] => moho2ug7zs57jijiywrewd8wb5a08h
            [swift-page-name] => permalink
            [swift-page-section] => permalink
            [al:ios:url] => twitter://status?id=1524828581536440320
            [al:ios:app_store_id] => 333903271
            [al:ios:app_name] => Twitter
            [al:android:url] => twitter://status?status_id=1524828581536440320
            [al:android:package] => com.twitter.android
            [al:android:app_name] => Twitter
            [type] => article
            [url] => https://twitter.com/MexicanSkynet/status/1524828581536440320
            [title] => SKYNΞT | 🔴 twitch.tv/mexicanskynet on Twitter
            [image] =>  
            [image:user_generated] => true
            [description] => “Hoy tenemos el mas pintoresco y tradicional torneo M7GP a las 9:00 pm CUU / 10:00 pm CDMX

Recuerda unirte al chat de voz: https://t.co/GGyxQJteMB
y recuerda sintonizarnos por: https://t.co/L0KmK5iRHt

#MarioKart8Deluxe #mariokart #nintendoswitch #twitchaffiliate”
            [site_name] => Twitter
            [fb:app_id] => 2231777543
        )

)

After commenting line 56 trough line 51 in src/OpenGraph.php it successfully generated the image url on this example:

Array
(
    [0] => Array
        (
            [robots] => NOODP
            [msapplication-TileImage] => //abs.twimg.com/favicons/win8-tile-144.png
            [msapplication-TileColor] => #00aced
            [facebook-domain-verification] => moho2ug7zs57jijiywrewd8wb5a08h
            [swift-page-name] => permalink
            [swift-page-section] => permalink
            [al:ios:url] => twitter://status?id=1524828581536440320
            [al:ios:app_store_id] => 333903271
            [al:ios:app_name] => Twitter
            [al:android:url] => twitter://status?status_id=1524828581536440320
            [al:android:package] => com.twitter.android
            [al:android:app_name] => Twitter
            [type] => article
            [url] => https://twitter.com/MexicanSkynet/status/1524828581536440320
            [title] => SKYNΞT | 🔴 twitch.tv/mexicanskynet on Twitter
            [image] => https://pbs.twimg.com/media/FSlHM2bWIAAQn-8.jpg:large
            [image:user_generated] => true
            [description] => “Hoy tenemos el mas pintoresco y tradicional torneo M7GP a las 9:00 pm CUU / 10:00 pm CDMX

Recuerda unirte al chat de voz: https://t.co/GGyxQJteMB
y recuerda sintonizarnos por: https://t.co/L0KmK5iRHt

#MarioKart8Deluxe #mariokart #nintendoswitch #twitchaffiliate”
            [site_name] => Twitter
            [fb:app_id] => 2231777543
        )

)

Expected behavior
Url array key should be populated if a twitter post has an image.

** System **
Laravel 8
PHP 7.4

Side note
anyone having problems getting metadata from socialmedia please use the following user agent set on this example:
$opg_array = OpenGraph::fetch('URL', true, null, null, 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)');

ErrorException: get_headers(): SSL: Connection reset by peer in

Describe the bug
I am encountering an error in the screenshot when trying to get the meta tags of an address.

Address: https://www.gittigidiyor.com/ev-bahce/ayakli-askilik-metal-konfeksiyon-askisi-elbise-askisi-ayakli-aski-rafli-askilik_pdp_555957549

To Reproduce
Steps to reproduce the behavior:

  1. Run the above address with OpenGraph::fetch()

Screenshots
image

UTF-8 image returns empty

Describe the bug
I'm using this tool to fetches images and titles from websites.
It's working great. Thanks!
I came across a UTF-8 encoded url of an image and the image returned empty

I'm using v1.0.6

To Reproduce
This is my code:

$url = 'https://unitedwithisrael.org/iranians-fall-in-love-with-israel-as-netanyahu-reaches-out-in-persian/';
$data = OpenGraph::fetch($url, true);

Expected behavior
i expected to get:

...
"image" => "https://unitedwithisrael.org/wp-content/uploads/2019/12/Screenshot_2019-12-10-اسرائیل-به-فارسی-IsraelPersian-Twitter-780x503.png"
"image:width" => "780"
"image:height" => "503"
...

But i got:

...
"image" => ""
"image:width" => "780"
"image:height" => "503"
...

Is there a way to get UTF-8 encoded url's returned correctly?

Thanks

Error when using

Hello how are you?
I started getting this error when using...

[2022-03-18 21:45:05] local.ERROR: Using $this when not in object context {"exception":"[object] (Error(code: 0): Using $this when not in object context at [...]back-end\vendor\shweshi\opengraph\src\OpenGraph.php:12)

Laravel 8.x
My code:
if (!$validator->fails()) { $data_group = OpenGraph::fetch($request->link); $validator->after(function ($validator) use ($data_group) { if(empty($data_group['title'])) { $validator->errors()->add('link', 'Error'); } }); }
I don't understand its origin or how to solve it...

Log errors from DOMDocument::loadHTML() using libxml_get_errors()

Retrieve the error by using libxml_get_errors() perform logging or return the list of issues to the caller.

$html = $this->curl_get_contents($url, $lang);
        /**
         * parsing starts here:.
         */
        $doc = new DOMDocument();

        $libxml_previous_state = libxml_use_internal_errors(true);
        $doc->loadHTML('<?xml encoding="utf-8" ?>'.$html);

        //catch possible errors due to empty or malformed HTML
        Log::warning(libxml_get_errors())

        libxml_clear_errors();
        // restore previous state
        libxml_use_internal_errors($libxml_previous_state);

Using Log::warning(libxml_get_errors()) is not compatible with PHP 5.6

Doesn't get the open graph data from Netflix

It doesn't seem to parse the open graph data from Netflix correctly.

When you fetch the open graph data from Netflix (any page on netflix.com) using OpenGraph::fetch('view-source:https://www.netflix.com/nl-en/title/70180387', true)

it only returns:

[
    "viewport" => "width=device-width, initial-scale=1",
]

while the tags seem to be present in the source:

<meta property="og:title" content="Homeland | Netflix"/>
<meta property="og:description" content="CIA analyst Carrie Mathison struggles with mental health and family issues while leading the war against terrorism in this political thriller series."/>
<meta property="og:url" content="https://www.netflix.com/nl-en/title/70180387" id="meta-url"/>
<meta property="og:image" content="https://occ-0-435-769.1.nflxso.net/dnm/api/v6/E8vDc_W8CLv7-yMQu8KMEC7Rrr8/AAAABecpPMdDJbTCAHnkTPNz5_MTnRfgAQ8NuGi1h2O_FZ5y-IcWYq-PZWQ9GhQ0zreFSDbmz48qepCON5qbqtFDq_wJn7dJ.jpg?r=286"/>
<meta property="al:ios:url" content="nflx://www.netflix.com/title/70180387?locale=en-NL"/>
<meta property="al:ios:app_store_id" content="363590051"/>
<meta property="al:ios:app_name" content="Netflix"/>
<meta property="al:android:url" content="nflx://www.netflix.com/title/70180387?locale=en-NL"/>
<meta property="al:android:package" content="com.netflix.mediaclient"/>
<meta property="al:android:app_name" content="Netflix"/>
<meta name="twitter:card" content="summary_large_image"/><meta name="twitter:site" content="@netflix"/>

Latest version doesn't supports Laravel v10

I see that composer.json file has been updated to support illuminate/log v10 but in latest tag it's still pulling the old composer.json with no support for v10.

Can you please release a new tag?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.