Open Graph Parser for Android

Overview

OpenGraphParser

A small and easy to use library which provides the convenience of using Open Graph Protocol in Android very easily. Create previews for links to share in Android very easily.

Star this repo to show your support stargazers for this repository. 🌟

OpenGraphParser.mp4

Add this in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
		...
			maven { url 'https://jitpack.io' }
		}
	}

Add the dependency

dependencies {
	   implementation 'com.github.Priyansh-Kedia:OpenGraphParser:<latest_version>'
	}

Implementation

private val openGraphParser = OpenGraphParser(this)

openGraphParser.parse(linkUrl) // To parse the link provided

The class required you to implement two callback functions, onError(error: String) and onPostResponse(openGraphResult: OpenGraphResult). The former is invoked in case of error (incorrect url), and the latter is invoked on successful response.

The data class OpenGraphResult contains:

  • title -> The title of the page the link points to
  • description -> The description metadata of the page
  • url -> The url of the page
  • image -> The image metadata for the page
  • siteName -> The name of the website (BASE URL).
  • type -> The type of the object e.g., "video.movie".

Inside onPostResponse(openGraphResult: OpenGraphResult) you can use the data to show on your UI like this.

override fun onPostResponse(openGraphResult: OpenGraphResult) {  
	linkPreviewLayout.apply {  
		Glide.with(this@ChannelActivity).load(openGraphResult.image).into(linkImage)  
		linkTitle.text = openGraphResult.title  
		linkDescription.text = openGraphResult.description  
		website.text = openGraphResult.siteName  
 	}}

Contributions

  • Fork the repo
  • Create a new branch and make changes
  • Push the code to the branch and make a PR! 👍

License

Copyright 2021 Priyansh Kedia

Permission 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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE 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.

Found this library useful? ❤️

Support it by joining stargazers for this repository. 🌟

Comments
  • Twitter og tags Problem

    Twitter og tags Problem

    Hi,

    First of all thank you for this useful library. But I couldn't get og tags for Twitter. I think this isJsoup problem. Do you know anything about this?

    opened by cagdasc 8
  • upgrade jsoup version to 1.13.1

    upgrade jsoup version to 1.13.1

    Issue: Was getting crash while parsing url on release builds (with minifyEnabled = true). Was unable to pull logs due to it being minified release build. Upgrading the version solved the issue.

    opened by ashishcors 5
  • Is the null check normal?

    Is the null check normal?

    First of all, I'm not good at English, so please forgive me.

    When checking for title and description null, is there any reason to use openGraphResult!!.title.equals("null") ? It's actually null, but it's not a string, so it's not a normal null check.

    library : openGraphResult!!.title?.isEmpty() == true || openGraphResult!!.title.equals("null")

    I think this is it openGraphResult!!.title?.isNullOrEmpty() == true || openGraphResult!!.title.equals("null")

    It's always in good use. please check.

    Thank you 😀

    opened by mazeloper 2
  • Some urls don't work.

    Some urls don't work.

    This library is working quite good in many cases. It's snappy and doesn't seem to consume many resources. It works good on recyclerviews as well.

    But, some urls, even popular ones such as www.google.com does not work. The return results are all 'null' and the error logs says that

    'Unable to resolve host "xn--()-3y0jv63bvsjymf": No address associated with hostname'

    Is there a workaround for this?

    opened by June6-android 2
  • Make the library reentrant and thread-safe

    Make the library reentrant and thread-safe

    Moves non-immutable variables from class-scope to function scope, and makes the constants shared across all class instances. This allows to make multiple concurrent calls to OpenGraphParser.parse without having different threads and coroutines interfere with each other

    opened by Mek101 1
Owner
Priyansh Kedia
Android Developer | Backend Developers | Active Open Source Contributor
Priyansh Kedia
A stock market app , with cached , search functionality , and market overview in the form of graph statics

A stock market app , with cached , search functionality , and market overview in the form of graph statics. The graph really looks cool (jetpack compose, SOLID priciples).

SUMIT KUMAR 1 May 20, 2022
Simple application with some famous graph algorithm implemented by Jetpack Compose framework

GraphAlgorithm This Application was implemented by Jetpack Compose framework. The dagger-hilt library was used for dependency injection and Room libra

Amirreza lotfi 8 Aug 17, 2022
Tournant is a Gourmand/Gourmet recipe parser which serves your dishes on your Android device

Tournant Gourmand/Gourmet recipe parser Website: tournant.zimbelstern.eu Tournant serves your favorite dishes on your Android device! With Tournant, y

null 5 Dec 23, 2022
ANTLR is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

Tunnel Vision Laboratories, LLC 53 Dec 18, 2022
A simple command line parser that takes different kind and format of inputs

CLI Parser Kata Introduction This is a simple command line parser that takes different kind and format of inputs and exports them to other format and

Victor Grycuk 0 Oct 5, 2021
Open Super dApp - Your gateway to the new digital commons. Integrated mobile messenger, Ethereum wallet, and Web 3.0 browser built on open, decentralized, and encrypted protocols.

A fully open source, open standard, decentralized "super app" including a secure, encrypted Matrix compatible messenger based off of the Element Messenger, and an Ethereum crypto wallet and web3 browser based off of Alpha Wallet.

2Gather 6 Jul 25, 2022
Ride-Sharing Uber Lyft Android App - Learn to build a ride-sharing Android Taxi Clone App like Uber, Lyft - Open-Source Project By MindOrks

Ride-Sharing Uber Lyft Android App - Learn to build a ride-sharing Android Taxi Clone App like Uber, Lyft - Open-Source Project By MindOrks

MindOrks 1.2k Dec 29, 2022
An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly.

An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly. The main aim of this repository is to help students who are learning Android Development or preparing for an Android Developer role-based job.

Mimo Patra 15 Dec 29, 2022
Open-source modular Android App IDE for Android

Blokkok Blokkok is an open-source modular Android App IDE for Android. Every components of the IDE are separated from each other by modules, every mod

null 14 Dec 16, 2022
An open source Hacker News client for Android.

Hacker News Come chat with us on Gitter.im! An open source Hacker News client for Android phones & tablets. Available on the Google Play Store How to

Matthew Bishop 227 Dec 11, 2022
An open source clone of a famous flappy bird game for Android using AndEngine

OpenFlappyBird An open source clone of a famous flappy bird game for Android using the amazing AndEngine History When the original Flappy Bird game wa

Dean Wild 299 Dec 26, 2022
A Free, Fully Fledged, Open-Source Music Player for Android

Turtle Player Free, Fully Fledged & Open-Source. The Music Player for Android. Turtle Player is designed to be a fun and unique app for playing your m

Edd Turtle 178 Nov 18, 2022
Freegemas libGDX is an Android and Java desktop port of Freegemas, which in turn is an open source version of the well known Bejeweled.

freegemas-gdx Freegemas libGDX is an Android, HTML 5 and Java desktop port of Freegemas, which in turn is an open source version of the well known Bej

David Saltares 144 Jun 21, 2022
Open source Imgur Android App

Opengur NO LONGER UNDER ACTIVE DEVELOPMENT Open source Imgur Android App Want to become a beta tester? Click Here! #Features Built in native java Nati

Kenny 324 Nov 22, 2022
Android open source calendar

Etar Calendar Etar (from Arabic: إِيتَار) is an open source material designed calendar made for everyone! Why? Well, I wanted a simple, material desig

null 1.5k Dec 30, 2022
Open source Imgur Android App

Opengur NO LONGER UNDER ACTIVE DEVELOPMENT Open source Imgur Android App Want to become a beta tester? Click Here! #Features Built in native java Nati

Kenny 324 Nov 22, 2022
Freegemas libGDX is an Android and Java desktop port of Freegemas, which in turn is an open source version of the well known Bejeweled.

freegemas-gdx Freegemas libGDX is an Android, HTML 5 and Java desktop port of Freegemas, which in turn is an open source version of the well known Bej

David Saltares 144 Jun 21, 2022
Free and open source manga reader for Android.

Build Stable Weekly Preview Contribute Support Server Tachiyomi Tachiyomi is a free and open source manga reader for Android 5.0 and above. Features F

Tachiyomi 20.4k Jan 9, 2023
Open source Crypto Currency Tracker Android App made fully in Kotlin

CoinBit CoinBit is a beautiful CryptoCurrency app, completely open sourced and 100% in kotlin. It supports following features Track prices of over 300

Pranay Airan 50 Dec 5, 2022