Connecting to Facebook with the C++ REST SDK

It’s very difficult to find C/C++ library to use for Windows, Mac ( and others ). There are some open sources, but they are kind of old and not updated. One of probably good thing is..  a module in MoSync library, but I worry about their license.

However, I found one on Microsoft Team blog about how to use “C++ REST SDK” for Facebook.

Connecting to Facebook with the C++ REST

The SDK is not made specifically for Facebook. It’s rather general.
So, people can access Facebook by doing things for themselves with the SDK.
( It’s like to use cURL for Twitter, although there is an existing library called twitcurl. )

Anyway, I wonder about login process with that. So, let’s read it.
The library itself can be obtained here.

Converting Unicode code point to surrogate representation

Although I looked up Unicode official web site, it was not possible to find how to convert Unicode code point to 4 bytes representation Emoticon uses. What’s weird about Emoticons are :

  • Unicode emoticon area is just smaller set of emoticons people think of
  • Some emoticons use Unicode code point, but some uses 4 bytes of Unicode sequence ( is there a name for this? )
  • Is there a rule to convert code point to the 4 bytes of sequence and to UTF-8?
    • There are some rule between code point and UTF-8

@gluebyte sent me a URL for a web site, which I found at work also but didn’t know there was conversion rule between code point and the 4 bytes of Unicode escape sequence. ( This is called surrogate code. So, it’s different from normal Unicode code point escape sequence. )

Actually, as for Unicode terminology, terminology is more difficult than what they mean.

Text Rendering : GDI, GDI+, etc

Why text appears different when drawn with GDIPlus versus GDI

The wonders of text rendering and GDI

OAuth 2 using curl

Trying out OAuth2 via CURL from h[y]tech blog.

It’s good to know that. As a long time user and developer for Unix, I have know cURL. It’s high-level program/library for various protocols and it’s sort of known that it can do everything.
However, buying tech book…? I don’t remember when is my last time such books. Nowadays I rely on Web. (although pedagogy style or explanation styles are not good especially blogs and web site created here in USA. usually Japanese ( of course ) or Korean ( if any ) writing style/books/posts on web are better for more concise and better explanation.

But.. anyway… Today I found very useful blog post on “How to do OAuth 2 with cURL”
Step by step and easy to understand one. It’s good because I don’t need to read MAN pages or documents on Web thoroughly. At least it can be good starting point to get some idea etc. Only when more information is needed, those more official document can be looked up.

More background information is located here : OAuth2: The Resource Owner Password Flow
Official document on OAuth is here : The OAuth 2.0 Authorization Framework


Of course, these SNS requires OAuth. (1.1 or 2.0+)


It’s better than Apple’s approach to block using old Xcode on newer OS X, at least

At home, I have Visual Studio 2010 Premium(?) and 2013 Express.
If I bring project file created and built using VS 2012 to home and tries to build with VS 2010 ( of course, I change settings in a project file to use 2010 toolset. ), it still fails and some error messages are not quite clear.
For example, __report_rangecheckfailure error is specific to VS 2012 and later project files.

It’s odd. But you can set it even for VS 2010.

Well, there are people who hate VS. But I like VS more overall ( especially Xcode 4 and later.. )
Apple prevents from using older Xcode on newer OS X.

commenting or documenting…

When I got interviewed, people tended to ask me, “Can you use Doxygen?”, “Can you use ‘some other document generator’?”.
Usually, when I am asked like that, it turned out that their documentation or whatever stuff they asked was not good in the company.

Commenting, or documenting in source files should be part of architecture, design or planning.
It’s not something you are to write after you implement something. It should be written before you start implementing something and while implementing.

What I mean is this. Commenting/Documenting is for maintainability or help for easier understanding of code.
If people make fun of you when you say “How bad it is! There is no comment!!”, then it’s Ok to treat them as non-professional people.
They will say “Real S/W engineers should be able to figure out without comment.”

Well.. they are only half-right. Sure. If you are a person who can think. Sure.. you can figure it out. However, just to use something and maintain, if you need to spend too much time, it’s not good. Commenting is to help that case. If it gives you an idea what the code part is for, you can get a pre-image to the code block. Then you can figure out things even quicker. Also, you can understand the original authors’ intention, suffering or odd situation they were in.

However, another very important reason for commenting is this.
It helps you to plan things better.
For example, even before writing, you can use your IDE/source code editor as a scratch paper like this.

void MyClass::doSomethingGreat( void )
// 1. Retrieve data from twitter

// 2. Check if there is user object in the response data

// 3. ...

Then, those commenting can plays very important role to aid you to organize your idea and split big task into small chunks.
You can get more rigid idea on what you are going to do. Sometimes by writing as such, something ambiguous can be clearer.
Also, after you write code, it can help you to locate interested portion of code quickly.
Then, it becomes great comment and documentation for itself. You don’t waste your time in writing comment/document. Your design time becomes your documenting time naturally.

Another very important point i would like to address is… Please use and pick terms others can use. Don’t use your own abbreviation and explain things really.

Here is a good example from twitcurl project.

* @method: twitCurl::mentionsGet
* @description: method to get mentions
* @input: sinceId - String specifying since id parameter

Especially take a lookat @input: sinceId line.
What is ‘sinceId’? that will be the question when you first confront the line.
Does “String specifying since id parameter”  really explain what sinceId is?
How about this?

* @method: twitCurl::timelineHomeGet
* @description: method to get home timeline
* @input: sinceId - the post ID for the last retrieved post.
*                                  Post with IDs after sinceID will to be retrieed

Isn’t that better? Anyway you should refer Twitter’s API documentation, but even without it, you can figure out what the sinceId means in that context.

I don’t count comment like the one in the mentionGet method.
You should not say you write comment if you write as shown in the mentionGet method.

C++ man pages from

Although I don’t like their articulation /pedagogy style…

I found an open source project here at GitHub. It is said to generate MAN page from contents.

If you use Mac, probably this program uses the cppman internally..

Additionally, there are some C++ reference MAN pages…

Well.. I don’t like general articulation style of MAN pages.
If Koreans write those, they should be like :

Class/Function name

What it is for

Parameter 1: 어쩌고 저쩌고 (간략한 것, 첫 문장. 자세한 거 한줄 띄고 그 후에)
Parameter 2 : 어쩌고 저쩌고

Return : 어쩌고 저쩌고 (간략한 것, 첫 문장. 자세한 거 한줄 띄고 그 후에)


Get every new post delivered to your Inbox.

Join 47 other followers

%d bloggers like this: