Skip to content

SocialLib handles sharing message to multiple social media.

License

Notifications You must be signed in to change notification settings

darkcl/SocialLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocialLib

CI Status Version License Platform

###What is SocialLib? SocialLib is a library that aims to share information to different social media site without getting your code messy with different social media SDKs.

Sharing with SocialLib is simple, you can have the same modal to share to different social media.

Here is an example for the same modal to share to Twitter and Facebook.

InfoModal.h

#import <Foundation/Foundation.h>

@interface InfoModal : NSObject <SocialLibFacebookMessage, SocialLibTwitterMessage>{
    
}

@property (nonatomic, strong) NSString *infoTitle;
@property (nonatomic, strong) NSString *infoContent;
@property (nonatomic, strong) NSString *infoContentURL;
@property (nonatomic, strong) NSArray *infoImages;
@property (nonatomic, strong) NSString *infoThumbnailImageURL;
@property (nonatomic, strong) NSString *infoVideoURL;

InfoModal.m

#import "InfoModal.h"


@implementation InfoModal

#pragma mark - SocialLibMessage
- (NSString *)title{
    return _infoTitle;
}

- (NSString *)content{
    return _infoContent;
}

- (NSString *)contentURL{
    return _infoContentURL;
}

- (NSArray *)images{
    return _infoImages;
}

- (NSString *)thumbnailImageURL{
    return _infoThumbnailImageURL;
}

- (NSString *)videoURL{
    return _infoVideoURL;
}

- (NSString *)tweetContent{
    return [NSString stringWithFormat:@"%@ - %@ %@",_infoTitle, _infoContent, _infoContentURL];
}

- (SocialLibTwitterMessageType)twitterMessageType{
    return SocialLibTwitterMessageTypeText;
}

- (SocialLibFacebookMessageType)fbMessageType{
    return SocialLibFacebookMessageTypeLink;
}

@end

To share facebook use

InfoModal *info = [[InfoModal alloc] init];
info.infoTitle = @"SocialLib";
info.infoContent = @"Share via SocialLib";
info.infoContentURL = @"http://darkcl.github.io/SocialLib";
[SocialLib shareModal:info
           toPlatform:kSocialLibPlatformFacebook
              success:^(NSDictionary *message) {
                  NSLog(@"%@", message);
              }
              failure:^(NSDictionary *message, NSError *error) {
                  NSLog(@"%@", error);
              }];

To share twitter use

InfoModal *info = [[InfoModal alloc] init];
info.infoTitle = @"SocialLib";
info.infoContent = @"Share via SocialLib";
info.infoContentURL = @"http://darkcl.github.io/SocialLib";
[SocialLib shareModal:info
           toPlatform:kSocialLibPlatformTwitter
              success:^(NSDictionary *message) {
                  NSLog(@"%@", message);
              }
              failure:^(NSDictionary *message, NSError *error) {
                  NSLog(@"%@", error);
              }];

Installation

SocialLib is available through CocoaPods. To install it, simply add the following line to your Podfile:

Install all platform (Facebook, Twitter, Tumblr, Instagram, Weibo and Weixin)

pod 'SocialLib'

For specific social platform, use subspec

pod 'SocialLib/Facebook'
pod 'SocialLib/Twitter'
pod 'SocialLib/Tumblr'
pod 'SocialLib/Instagram'
pod 'SocialLib/Weibo'
pod 'SocialLib/Weixin'

Setup Guide

You can find setup guide in the wiki

Usage

To run the example project, clone the repo, and run pod install from the Example directory first. Demo provided Facebook, Twitter and Tumblr api keys, Weibo and Weixin api keys are empty

Author

Yeung Yiu Hung, hkclex@gmail.com

License

SocialLib is available under the MIT license. See the LICENSE file for more info.

Bitdeli Badge

About

SocialLib handles sharing message to multiple social media.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages