GitXplorerGitXplorer
j

Crackle

public
35 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
023be5d71985edf3017c57de13ecaa46e777a928

Merge pull request #3 from strand/patch-1

jjordanekay committed 10 years ago
Unverified
51c8bf689ec06f0b6d7c534e73519d4fcb73c58a

Update Contributor Covenant to 1.1.0

jjohana-star committed 10 years ago
Unverified
0ce06412b27c971ea1dc5473dae39c9e47bee318

Post notification when authorization web view fails to load request

committed 11 years ago
Unverified
02087f1405008fe92596968becdc94d7f8cdf9bc

Support denied access use case during authorization

committed 11 years ago
Unverified
c31c95eb447327ea4f5b3376a4c7546863f46989

Remove references to CrackedMantle

committed 11 years ago
Unverified
d5b4507d5ce74be706b52b1ff29bf7ab68a15676

Show network activity indicator while authorization web view is loading

committed 11 years ago

README

The README file for this repository.

Crackle

Crackle is an Objective-C wrapper around the 37signals Campfire API.

Functionality

Crackle covers all major endpoints provided by the Campfire API, with support for multiple accounts.

Account

  • Get info for an authorized account GET /account.xml

      +[CKLCampfireAPI getInfoForAccount:responseBlock:]
    

Message

  • Get recent messages from a room GET /room/#{id}/recent.xml

      +[CKLCampfireAPI getRecentMessagesForRoom:responseBlock:]
      +[CKLCampfireAPI getRecentMessagesForRoom:sinceMesssage:responseBlock:]
      +[CKLCampfireAPI getRecentMessagesForRoom:sinceMessage:withLimit:responseBlock:]
    
  • Get messages from a room sent on a specific date GET /room/#{id}/transcript.xml, GET /room/#{id}/transcript/#{year}/#{month}/#{day}.xml

      +[CKLCampfireAPI getTodaysMessagesForRoom:responseBlock:]
      +[CKLCampfireAPI getMessagesForRoom:fromDate:responseBlock:]
    
  • Search for messages across all rooms GET /search?q=#{term}&format=xml

      +[CKLCampfireAPI getMessagesWithQuery:account:responseBlock:]
    
  • Send a message to a room POST /room/#{id}/speak.xml

      +[CKLCampfireAPI sendMessage:toRoom:responseBlock:]
    
  • Toggle message starred POST /messages/#{message_id}/star.xml, DELETE /messages/#{message_id}/star.xml

      +[CKLCampfireAPI starMessage:responseBlock:]
    
  • Stream messages from a room GET https://streaming.campfirenow.com/room/#{id}/live.json

      +[CKLCampfireAPI streamMessagesInRoom:responseBlock:]
    

Room

All actions are performed from the account authenticated to access the room object.

  • Get visible and active rooms GET /rooms.xml, GET /presence.xml

      +[CKLCampfireAPI getVisibleRoomsForAccount:responseBlock:]
      +[CKLCampfireAPI getActiveRoomsForAccount:responseBlock:]
    
  • Get info (including the list of users) for room GET /room/#{id}.xml

      +[CKLCampfireAPI getInfoForRoom:responseBlock:]
    
  • Update room with a new name and/or topic PUT /room/#{id}.xml

      +[CKLCampfireAPI updateRoom:withName:topic:responseBlock:]
    
  • Join or leave room POST /room/#{id}/join.xml, POST /room/#{id}/leave.xml

      +[CKLCampfireAPI joinRoom:responseBlock:]
      +[CKLCampfireAPI leaveRoom:responseBlock:]
    
  • Lock or unlock room POST /room/#{id}/lock.xml, DELETE /room/#{id}/lock.xml

      +[CKLCampfireAPI lockRoom:responseBlock:]
      +[CKLCampfireAPI unlockRoom:responseBlock:]
    

Upload

  • Upload an image to a room POST /room/#{id}/uploads.xml

      +[CKLCampfireAPI uploadImage:toRoom:responseBlock:]
    
  • Get recent uploads for room GET /room/#{id}/uploads.xml

      +[CKLCampfireAPI getRecentUploadsForRoom:responseBlock:]
    
  • Get upload for specific message GET /room/#{id}/messages/#{upload_message_id}/upload.xml

      +[CKLCampfireAPI getUploadForMessage:responseBlock:]
    

User

  • Get info for current user GET /users/me.xml

      +[CKLCampfireAPI getInfoForUserForCurrentAccount:responseBlock:]
    
  • Get info for specific user GET /users/#{id}.xml

      +[CKLCampfireAPI getInfoForUser:responseBlock:]
    

Authentication

Crackle uses OAuth 2 to authenticate the user with your app. Register your app’s client ID, client secret, and redirect URI with

+[CKLCampfireAPI setClientID:secret:redirectURI:]

Then call

+[CKLCampfireAPI authorizeWithWebView:]

to display the 37signals login form in a UIWebView, followed by a permission screen for allowing your app to access the user’s account. Once authentication is finished, the account’s access token is stored securely in the Keychain.

Login Form Permission Dialog

Examples

// Find a room to join
__block CKLCampfireRoom *room;
[CKLCampfireAPI getVisibleRoomsForAccount:account responseBlock:^(NSArray *array, NSError *error) {
    room = [array firstObject];
    // Join the room
    [CKLCampfireAPI joinRoom:room responseBlock:^(NSError *error) {
        // Stream messages from the room
        __block NSUInteger messageCount = 0;
        [CKLCampfireAPI streamMessagesInRoom:room responseBlock:^(CKLCampfireMessage *message, NSError *error) {
            // Print each message as it comes in
            if (message.body) {
                NSLog(@"%@", message.body);
                messageCount++;
            }

            // After a number of messages come in
            if (messageCount == MESSAGES_TO_STREAM) {
                // Send a message to the room
                CKLCampfireMessage *message = [CKLCampfireMessage postingMessageWithBody:@"Goodbye!" ofType:CKLCampfireMessageTypeText];
                [CKLCampfireAPI sendMessage:message toRoom:room responseBlock:^(CKLCampfireMessage *message, NSError *error) {
                    // Leave the room
                    [CKLCampfireAPI leaveRoom:room responseBlock:^(NSError *error) {
                        
                    }];
                }];
            }
        }];
    }];
}];

Version

0.9.0

License

MIT