Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jverdi/gramophone
Gramophone is a framework for interacting with the Instagram REST API, written in Swift.
https://github.com/jverdi/gramophone
instagram instagram-api instagram-client ios swift
Last synced: 3 months ago
JSON representation
Gramophone is a framework for interacting with the Instagram REST API, written in Swift.
- Host: GitHub
- URL: https://github.com/jverdi/gramophone
- Owner: jverdi
- License: mit
- Created: 2017-04-10T19:15:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-14T17:16:14.000Z (over 7 years ago)
- Last Synced: 2024-03-14T20:21:55.685Z (10 months ago)
- Topics: instagram, instagram-api, instagram-client, ios, swift
- Language: Swift
- Size: 1.36 MB
- Stars: 18
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/jverdi/Gramophone.svg?branch=master)](https://travis-ci.org/jverdi/Gramophone)
[![CocoaPods compatible](https://img.shields.io/cocoapods/v/Gramophone.svg)](#cocoapods)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage)
[![GitHub release](https://img.shields.io/github/release/jverdi/Gramophone.svg)](https://github.com/jverdi/Gramophone/releases)
[![Swift 4.0](https://img.shields.io/badge/Swift-4.0-orange.svg)](#)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](http://jaredverdi.mit-license.org)
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](http://twitter.com/jverdi)Gramophone is a framework for interacting with the Instagram REST API, written in Swift.
It includes authentication via OAuth, and methods to make asynchronous network calls to all of Instagram's publicly available API endpoints.
Responses are parsed into concrete model objects and errors.
## Usage
Setup the client, supplying your Instagram [client id and redirect URI](https://www.instagram.com/developer/clients/manage/), as well as any desired [scopes](https://www.instagram.com/developer/authorization/):
```swift
import Gramophonelet configuration = ClientConfiguration(
clientID: "{YOUR_INSTAGRAM_CLIENT_ID}",
redirectURI: "{YOUR_INSTAGRAM_REDIRECT_URI}",
scopes: [.basic, .publicContent, .comments]
)
let gramophone = Gramophone(configuration: configuration)
```Authenticate using OAuth (with an in-app `WKWebView` controller):
```swift
gramophone.client.authenticate(from: presentingViewController) { result in
switch result {
case .success(let response):
print("Authenticated")case .failure(let error):
print("Failed to authenticate: \(error.localizedDescription)")
}
}
```Request data using one of the API wrapper methods:
```swift
gramophone.client.myRecentMedia(options: nil) { mediaResult in
switch mediaResult {
case .success(let response):
let mediaItems = response.data.items
for media in mediaItems {
if let images = media.images, let rendition = images[.thumbnail] {
print("Media [ID: \(media.ID), url: \(rendition.url)]")
}
}
case .failure(let error):
print("Failed to load media: \(error.localizedDescription)")
}
}
```See the [Resources](http://github.com/jverdi/Gramophone/tree/master/Source/Resources) directory for the full listing of available API methods:
| API Wrapper | Methods | Instagram Docs |
| ------------- | ------------- | ------------- |
| [Auth](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/Auth.swift) |
- ```authenticate(from:) => String```
| [Comments](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/CommentsAPI.swift) |
- ```comments(mediaID:) => Array```
- ```postComment(_:mediaID:) => NoData```
- ```deleteComment(mediaID:commentID:) => NoData```
| [Likes](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/LikesAPI.swift) |
- ```likes(mediaID:) => >```
- ```like(mediaID:) => NoData```
- ```unlike(mediaID:) => NoData```
| [Locations](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/LocationsAPI.swift) |
- ```location(ID:) => Location```
- ```locationRecentMedia(ID:options:) => Array```
- ```locations(latitude:longitude:distanceInMeters:) => Array```
| [Media](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/MediaAPI.swift) |
- ```media(withID:) => Media```
- ```media(withShortcode:) => Media```
- ```media(latitude:longitude:distanceInMeters:) => Array```
| [OEmbed](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/OEmbed.swift) |
- ```oembed(url:) => EmbedMedia```
| [Relationships](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/RelationshipsAPI.swift) |
- ```myFollows() => Array```
- ```myFollowers() => Array```
- ```myRequests() => Array```
- ```relationship(withUserID:) => IncomingRelationship```
- ```followUser(withID:) => OutgoingRelationship```
- ```unfollowUser(withID:) => OutgoingRelationship```
- ```approveUser(withID:) => IncomingRelationship```
- ```ignoreUser(withID:) => IncomingRelationship```
| [Tags](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/TagsAPI.swift) |
- ```tag(name:) => Tag```
- ```tagRecentMedia(name:options:) => Array```
- ```tags(query:options:) => Array```
| [Users](http://github.com/jverdi/Gramophone/blob/master/Source/Resources/UsersAPI.swift) |
- ```me() => User```
- ```user(withID:) => User```
- ```myRecentMedia(options:) => Array```
- ```userRecentMedia(withID:options:) => Array```
- ```myLikedMedia(options:) => Array```
- ```users(query:options:) => Array```
## Installation
### CocoaPods
To integrate Gramophone using [CocoaPods](http://cocoapods.org), add it to your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '{YOUR_TARGET}' do
pod 'Gramophone', '~> 1.1'
end
```
Then, run:
```bash
$ pod install
```
### Carthage
To integrate Gramophone using [Carthage](https://github.com/Carthage/Carthage), add it to your `Cartfile`:
```ogdl
github "jverdi/Gramophone" ~> 1.1
```
Then, run:
```bash
$ carthage update --platform iOS
```
and drag the built `Gramophone.framework`, `Decodable.framework`, and `Result.framework` into your Xcode project's Embedded Binaries from `Carthage/Build/iOS`.
## Dependencies
Gramophone makes use of the [Decodable](https://github.com/Anviking/Decodable) and [Result](https://github.com/antitypical/Result) libraries.
## License
Gramophone is released under the MIT license. See [LICENSE](https://github.com/jverdi/Gramophone/blob/master/LICENSE) for details.
Icon created by Gan Khoon Lay from the Noun Project