The Sina Weibo open platform provides a wide range of Weibo operation APIs. developers can use the APIs to develop their desired features, or connect their websites and applications to the Weibo open platform, you can even develop a fully functional Sina Weibo client (weico) or web page (mini Weibo http://sinaweibopy.sinaapp.com /). In short, the function is very powerful, to provide you with a very large space to play, specific can refer to the official instructions: http://open.weibo.com /.
Beginners (I am also a beginner) can start by developing some simple programs, such: use your own program to send a new microblog, get friends you are interested in, get fans of yourself, and get Weibo posts from friends. Further, you can do some simple analysis work. For example: analyze the gender ratio among all of your friends and the Time Distribution of Weibo posts by friends. If you are a super girl, you can develop programs with more powerful functions, such: develop a bot that automatically replies to Weibo. It can process and understand the natural language of the microblog and then automatically reply to the corresponding content (it is interesting to think about it, but it is not easy for me to do it ). In addition, there are already many commercial Weibo analysis tools available on the market, which is even more powerful.
This document describes how to use the official Python SDK of Sina Weibo to call APIs for development.
1. apply to become a developer and create an application
First of all to have a Sina Weibo account, and then go to Sina Weibo Open Platform (http://open.weibo.com/) to create an application, the specific steps of the official website documentation is very detailed (http://open.weibo.com/wiki/%E6%96%B0%E6%89%8B%E6%8C%87%E5%8D%97 ). After the application is successful, app_key and app_secret will be obtained. These two constants are used for subsequent authorization. Note that the application needs to set a callback address (call_back), as shown in. In application management, locate the location set for the callback address and fill in your webpage address for callback, beginner developers may not have and do not need to call back the webpage. In fact, you can set a URL or the default callback URL: callback. After this step is completed, three useful information will be obtained: app_key, app_secret, and call_back, which will be used in subsequent programming.
Now, you can use the SDK to compile the program. A friend asked if the "not reviewed" status of the application had any effect, but it did not, apart from the differences between some special APIs and permission levels, you can call and compile programs.
Second: carefully study the authorization mechanism oauth2.0
Official documentation.
Third: download and install Sina Weibo Python SDK
Liao Xuefeng, author of Sina Weibo Python SDK, provided a description on the webpage. In fact, beginners only need to focus on one step, that is, installing the SDK. The web page shows two installation methods: the first is to use the command line tool pip for installation, and the second is to download the source code package for installation. The first installation method is recommended here, because it is troublesome to copy the source code package to the installation directory or configure the path searched by the python module.
Pip is a python package management tool. If you are not familiar with Pip, you can check related materials. PIP can easily install the python module. After the installation is successful, you only need to execute Pip in the command line (or Linux terminal ).
Install sinaweibopy. the SDK package sinaweibopy is installed. To test whether the installation is successful, enter import Weibo in the python command line. If no error message is displayed, the installation is successful. In fact, the python SDK mainly refers to the module Weibo, and the functions in this module will be called later when the SDK is used.
Now that the preparation is complete, you can call the API to compile the Weibo Operation Program. The next article will provide an example of Weibo.
By: