Created
February 14, 2017 16:04
-
-
Save noppefoxwolf/156f23b17aeba9f7b4deb4972062ba85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import TwitterVideoUploader | |
import STTwitter | |
import RxSwift | |
import MobileCoreServices | |
final class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
let ๐ = DisposeBag() | |
override func viewDidAppear(_ animated: Bool) { | |
let vc = UIImagePickerController() | |
vc.sourceType = .photoLibrary | |
vc.mediaTypes = [kUTTypeMovie as String] | |
vc.delegate = self | |
present(vc, animated: true, completion: nil) | |
} | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { | |
guard let url = info[UIImagePickerControllerMediaURL] as? URL else { return } | |
post(videoUrl: url) | |
} | |
private func post(videoUrl: URL) { | |
//post | |
let api = STTwitterAPI(oAuthConsumerKey: "", | |
consumerSecret: "", | |
oauthToken: "", | |
oauthTokenSecret: "") | |
api?.postStatusesUpdate(with: videoUrl, message: "test").subscribe(onNext: { (_) in | |
print("next") | |
}, onError: { (error) in | |
print("error", error) | |
}, onCompleted: { | |
print("complete") | |
}, onDisposed: { | |
print("dispose") | |
}).addDisposableTo(๐) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment