Created
February 27, 2022 02:15
-
-
Save mironal/6ad38705ad729c71afec9816abccbfd4 to your computer and use it in GitHub Desktop.
Sample code for Search Stream API using TwitterAPIKit.
This file contains 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
func testExample() throws { | |
let client = TwitterAPIKit( | |
.bearer( | |
"<your token>" | |
)) | |
let exp = expectation(description: "") | |
/* | |
// Before starting a Stream search, you need to add a Rule for the search. | |
client.v2.stream.postSearchStreamRules( | |
.init(operation: .add([.init(value: "cat has:media", tag: "cats with media")])) | |
).responseObject { response in | |
print(response.prettyString) | |
exp.fulfill() | |
} | |
client.v2.stream.getSearchStreamRules(.init()).responseObject { response in | |
print(response.prettyString) | |
exp.fulfill() | |
} | |
*/ | |
client.v2.stream.searchStream(.init()).streamResponse(queue: .global(qos: .default)) { response in | |
print(response.prettyString) | |
} | |
wait(for: [exp], timeout: 60) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment