Skip to content

Instantly share code, notes, and snippets.

@devStepsize
devStepsize / wechat_image.m
Last active March 14, 2017 14:23
Share an image from your iOS app to WeChat using their API / SDK
// Start by instantiating the message
WXMediaMessage *message = [WXMediaMessage message];
// Set (optional) title, description, and thumbnail
message.title = @"Some Title";
message.description = @"Amazing Sunset";
[message setThumbImage:[UIImage imageNamed:@"res1thumb.png"]];
// Create the image object and attach it to the message
WXImageObject *ext = [WXImageObject object];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"res1" ofType:@"jpg"];
@devStepsize
devStepsize / embed_website_facebook.html
Created April 20, 2016 14:53
Meta tags to embed our website properly when it is shared on Facebook
<!-- Open Graph data -->
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:image" content="http://example.com/image.jpg" />
<meta property="og:description" content="Description Here" />
<meta property="og:site_name" content="Site Name, i.e. Moz" />
<meta property="og:price:amount" content="15.00" />
<meta property="og:price:currency" content="USD" />
@devStepsize
devStepsize / wechat_music.m
Last active April 20, 2016 16:00
Share music from your iOS app to WeChat using their API / SDK
// Start by instantiating the message
WXMediaMessage *message = [WXMediaMessage message];
// Set (optional) title, description, and thumbnail
message.title = @"Song Title";
message.description = @"Amazing Song";
[message setThumbImage:[UIImage imageNamed:@"res1thumb.png"]];
// Create the music object and attach it to the message
WXMusicObject *ext = [WXMusicObject object];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"res1" ofType:@"jpg"];
@devStepsize
devStepsize / wechat_video.m
Last active April 20, 2016 15:59
Share a video from your iOS app to WeChat using their API / SDK
// Start by instantiating the message
WXMediaMessage *message = [WXMediaMessage message];
// Set (optional) title, description, and thumbnail
message.title = @"Video Title";
message.description = @"Amazing Video";
[message setThumbImage:[UIImage imageNamed:@"res2.jpg"]];
// Create the video object and attach it to the message
WXVideoObject *ext = [WXVideoObject object];
ext.videoUrl = @"http://www.youtube.com/watch?v=UF8uR6Z6KLc";
@devStepsize
devStepsize / wechat_link.m
Last active April 20, 2016 17:05
Share a video from your iOS app to WeChat using their API / SDK
@devStepsize
devStepsize / minimum_social_media_tag_template.html
Created April 20, 2016 15:05
Minimum metatags that we need to add to the website HTML for it to embed nicely on Twitter and Facebook
<!-- Place this data between the <head> tags of your website -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer than 155 characters." />
<!-- Twitter Card data -->
<meta name="twitter:card" value="summary">
<!-- Open Graph data -->
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />
@devStepsize
devStepsize / wechat_text.m
Last active April 20, 2016 15:59
Share a text message from your iOS app to WeChat using their API / SDK
// To share text messages, you only need the below
SendMessageToWXReq *req = [[[SendMessageToWXReq alloc] init] autorelease];
req.text = @"Your Text Message.";
req.bText = YES;
// Uncomment the 1st line to share to WeChat contacts, or the 2nd line to share to WeChat Moments
// req.scene = WXSceneSession;
// req.scene = WXSceneTimeline;
[WXApi sendReq:req];
@devStepsize
devStepsize / wechat_import.m
Created April 20, 2016 16:19
Import statements for the files in which you wish to use the WeChat API
#import <UIKit/UIKit.h>
#import "WXApi.h"
// Add the WXApiDelegate protocol
@interface AppDelegate : UIResponder <UIApplicationDelegate, WXApiDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@devStepsize
devStepsize / twilio_send_sms.py
Last active April 21, 2016 21:17
Code snippet to send an SMS to given number
message = client.sms.messages.create(
to="+12316851234",
from_="+15555555555",
body="Hello there!"
)
@devStepsize
devStepsize / twilio_send_mms.py
Last active April 21, 2016 21:41
Send an MMS to a given number with Twilio
message = client.messages.create(
body="Hello Monkey!", # Message body, if any
to="+12125551234",
from_="+15105551234",
media_url=[ # List of media URLs, if any
"http://example.com/image1.jpg",
"http://example.com/image2.jpg",
],
)