翻了下以前的日记,决定把一些笔记晒出来分享,需求是这样,需要通过c/c++写的应用实现上传图片等到facebook,以下是用curl模拟的登录facebook,并取得权限的一些记录,有可能facebook的接口已经改了,但是原理是一样的,能用curl命令实现,c/c++就可以调用libcurl来实现程序控制的。 要有权限就得有access token 得到access token的一种方式 1. Embed a web browser and implement the client-side authentication flow: https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token
2. After the user authorizes your app, Facebook will redirect the user to that URL and pass an the access token in the URI fragment:
You should detect this redirect and then read the access token out of the URI using whatever mechanisms provided by your OS and development framework of choice. 有了access token就可以做很多事,比如上传图片
其他的一些有用的资料: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow This guide will take you through each step of the login flow and show you how to implement each one without using our SDKs: