Latest 1.1.0
Homepage https://github.com/satoshi-takano/OpenGraph
License MIT The MIT License (MIT)
Copyright (c) 2018 Satoshi Takano
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.
Platforms ios 8.0, osx 10.9, tvos 9.0, watchos 2.0

A Swift wrapper for the Open Graph protocol (OGP)

Build Status Carthage compatible Platform
OpenGraph is a Swift wrapper for the OGP (Open Graph protocol).
You can fetch OpenGraph,then you can access the attributes with subscript and the key provided by enum type.

OpenGraph.fetch(url) { og, error in
    print(og?[.title]) // => og:title of the web site
    print(og?[.type])  // => og:type of the web site
    print(og?[.image]) // => og:image of the web site
    print(og?[.url])   // => og:url of the web site
}

If you want to use Rx interface, use an extension below.

extension OpenGraph {
    static func rx_fetch(url: URL?) -> Observable<OpenGraph?> {
        return Observable.create { observer in
            guard let url = url else {
                observer.onCompleted()
                return Disposables.create()
            }

            OpenGraph.fetch(url: url) { og, err in
                if let og = og {
                    observer.onNext(og)
                }
                if let err = err {
                    observer.onError(err)
                }

                observer.onCompleted()
            }

            return Disposables.create()
        }
    }
}

Requirements

  • Xcode 9 / Swift 4.0 or 3.2 (If you use Xcode 8.x, you can use 1.0.2.)
  • iOS 8.0 or later
  • macOS 10.9 or later
  • tvOS 9.0 or later
  • watchOS 2.0 or later

If you use Swift 2.2 or 2.3, use older version of OpenGraph.

Installation

CocoaPods

Insert pod 'OpenGraph' to your Podfile and run pod install.

Carthage

Insert github "satoshi-takano/OpenGraph" to your Cartfile and run carthage update.

License

This project and library has been created by Satoshi Takano and is under the MIT License.

Latest podspec

{
    "name": "OpenGraph",
    "version": "1.1.0",
    "summary": "A Swift wrapper for the Open Graph protocol.",
    "homepage": "https://github.com/satoshi-takano/OpenGraph",
    "license": {
        "type": "MIT",
        "text": "The MIT License (MIT)nCopyright (c) 2018 Satoshi TakanonPermission 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:nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.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"
    },
    "authors": "satoshi-takano",
    "description": "OpenGraph is a Swift wrapper for the Open Graph protocol. You can fetch OpenGraph,then you can access the attributes with subscript and the key provided by enum type.",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "source": {
        "git": "https://github.com/satoshi-takano/OpenGraph.git",
        "tag": "1.1.0"
    },
    "source_files": "OpenGraph/*.{swift,h,m}"
}

Pin It on Pinterest

Share This