A kind of SNS platform authorization requests acquisition methods, information issuing method and its storage equipmentTechnical field
The present invention relates to a kind of SNS platform authorization requests acquisition methods, information issuing method and its storage equipment, are related to mutuallyNetworking arenas.
Background technique
SNS, full name SocialNetworking Services, i.e. social network services, is specially intended to that people is helped to establishThe Internet application service of social network.1967, the psychology professor StanleyMilgram of Harvard University (1934~1984) six degrees of separation theory has been founded, briefly:" people that you are spaced between any one stranger does not exceed sixIt is a, that is to say, that at most by six people, you can recognize any one stranger." according to six degrees of separation theory, per each and every oneThe social circle of body all constantly amplifies, and finally becomes a catenet.This is social network (SocialNetworking)Early stage understands.Later someone has founded the Internet service of property network towards the society, by the way that " acquaintance's is ripe according to this theoryPeople " carries out network social intercourse expansion.In society, the exchange of person to person is by interpersonal introduction, shakes hands come shapeIt is enclosed at a circle of friends, connection, everyone does not need directly to recognize owner, it is only necessary to pass through his friend, the friend of friendFriend can facilitate and once shake hands.And common Computer Mediated Communication, then it is most of to be realized by certain platforms, for example oneself is putInto a platform, many people is allowed to see, and contacts you and recognize you.The advantage and disadvantage of the two are obvious, social communication advantageIt is that reliably, relationship is established on reliable interpersonal relationships net each other, the disadvantage is that generating, the time shaken hands is long, and cost is higher, platform-typeComputer Mediated Communication advantage is at low cost, but unreliable.With the fast development of internet, the social activity of people is also gradually from realityLife is transferred to internet, and different social platforms often has the absorbed field for oneself being different from other platforms, peopleOften suffer from the account of oneself in different platforms, therefore just there are more and more enterprises to start in different social platformsIt establishes the homepage issuing advertisement of oneself, promote product.
Since more and more outstanding SNS platforms continue to bring out, company manager is also required to different SNS platforms and establishesHomepage, when needing releasing advertisements or promoting product, it is necessary to go major SNS platform to log in postedit information, then issueInformation.Although major SNS platform is all provided with api interface now, due to OAuth certification have it is 1.0 and 2.0 two differentMode, this adds increased the docking difficulty of developer.
When needing to increase a new SNS platform, it is to be understood that the api interface that it is provided be based on OAuth1.0 orThen OAuth2.0 identifying procedure establishes the interface class of API docking according to OAuth version.
Since the identifying procedure of OAuth1.0 is different from OAuth2.0, and the api interface identifying procedure of different SNS platformsThere are also subtle difference, developer requires to consult each platform since authenticating step when docking different SNS platforms every timeAPI document.
Company manager to Mr. Yu advertisement or some popularization product is inconvenient to which platform known to have issued.
Summary of the invention
The present invention provides a kind of SNS platform authorization requests acquisition methods, and are easy to implement the storage equipment of this method, toolHave convenient for saving development process, the characteristics of client faster obtains corresponding SNS platform authorization.
The present invention also provides a kind of methods using authorized SNS platform release information, and are easy to implement the partyThe storage equipment of method has convenient for saving development process, and client can faster utilize authorized SNS platform invention informationThe characteristics of.
A kind of SNS platform authorization requests acquisition methods provided according to the present invention, method include:
Client sends SNS platform authorization requests;
Server-side receives the SNS platform authorization requests of client transmission, and inquires requested SNS platform configuration information;The configuration information includes OAuth version information, Scope, APPSecret and APPID;
Server-side judges the version that requested SNS platform is based on for OAuth1.0 version according to OAuth version informationOr OAuth2.0 version;
It is executed if version is OAuth1.0 version:
The parameter of request is generated signature signature according to OAuth1.0 standard;
To corresponding api interface request RequestToken, and receive return RequestToken andRequestSecret;
The RequestToken and RequestSecret returned according to interface goes SNS platform to request finallyAccessToken and Token expired time;
It is executed if version is OAuth2.0 version:
AuthCode is requested to corresponding api interface, and receives the AuthCode of return;
SNS platform is gone to request final AccessToken and Token using the AuthCode that corresponding api interface returnsExpired time;
Server-side passes through the acquisition authorization user information of each SNS platform according to the final AccessToken gotApi interface obtain user basic information;The elemental user information includes user's pet name, user's head portrait and User ID.
The method also includes, server-sides according to the API RequestToken returned and RequestSecret, orAuthCode combines the OAuth required parameter of corresponding version;According to combined required parameter, corresponding SNS platform authorization is jumped toThe page makes client user log in SNS account to authorize;
Judge whether user agrees to authorize, if agreeing to authorization, records the AccessToken's and Token of API returnExpiration time;If disagreeing authorization, record log, authorization flow terminates.
The method also includes:After client user edits the information for needing to issue, selection needs the authorization SNS issuedPlatform;Server-side needs the information issued to be published to major SNS platform in order according to current task amount, user.
A kind of method using authorized SNS platform release information provided according to the present invention, it is flat based on above-mentioned SNSPlatform authorization requests acquisition methods, method include:
Client user edits the information to be issued and selects authorized SNS platform;
Server-side reads the AccessToken authorized and judges corresponding SNS platform OAuth version;If it isThe platform of OAuth1.0 then generates corresponding signature signature according to the parameter of this request;Request each SNS platformThe api interface of release information submits the text information for needing to issue and uploading pictures data;SNS platform api interface is received to returnPublication whether successful information.
The method also includes recording publication successful information if issued successfully;If publication failure, records mistakeLose log.
A kind of storage equipment provided according to the present invention, is stored with a plurality of instruction, and described instruction includes adding convenient for processorIt carries and handles:
Receive the SNS platform authorization requests of client transmission, and inquires requested SNS platform configuration information;It is described to matchConfidence breath includes OAuth version information, Scope, APPSecret and APPID;
According to OAuth version information judge the version that requested SNS platform is based on for OAuth1.0 version stillOAuth2.0 version;
It is executed if version is OAuth1.0 version:
The parameter of request is generated signature signature according to OAuth1.0 standard;
To corresponding api interface request RequestToken, and receive return RequestToken andRequestSecret;
The RequestToken and RequestSecret returned according to interface goes SNS platform to request finallyAccessToken and Token expired time;
It is executed if version is OAuth2.0 version:
AuthCode is requested to corresponding api interface, and receives the AuthCode of return;
SNS platform is gone to request final AccessToken and Token using the AuthCode that corresponding api interface returnsExpired time;
According to the final AccessToken got, pass through the acquisition authorized client user information of each SNS platformApi interface obtain client user's essential information;The elemental user information includes user's pet name, user's head portrait and userID。
Described instruction further includes loading and handling convenient for processor:According to API return RequestToken andRequestSecret or AuthCode combines the OAuth required parameter of corresponding version;According to combined required parameter, jumpMake client user log in SNS account to corresponding SNS platform authorization page to authorize;
Judge whether user agrees to authorize, if agreeing to authorization, records the AccessToken's and Token of API returnExpiration time;If disagreeing authorization, record log, authorization flow terminates.
Described instruction further includes loading and handling convenient for processor:According to current task amount, client user is neededThe information of publication is published to major SNS platform in order.
Described instruction further includes loading and handling convenient for processor:
The authorized SNS platform of the information to be issued and selection that reading client user edits;According to having authorizedAccessToken and judge corresponding SNS platform OAuth version;If it is the platform of OAuth1.0, then according to this requestParameter generate corresponding signature signature;It requests the api interface of the release information of each SNS platform to be submitted to need to issueText information and uploading pictures data;Receive SNS platform api interface return publication whether successful information.
Described instruction further includes loading and handling convenient for processor:
If issued successfully, publication successful information is recorded;If publication failure, records unsuccessfully log.
Compared with prior art, convenient for saving development process, client can be obtained faster accordingly technical solution of the present inventionSNS platform authorization and release information, and it is conducive to the maintenance and management of later period personnel.
Detailed description of the invention
Fig. 1 is the SNS platform authorization requests acquisition methods process schematic illustration of a wherein embodiment of the invention.
Fig. 2 is the utilization method flow principle that authorized SNS platform releases news of a wherein embodiment of the inventionSchematic diagram.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, rightThe present invention is further elaborated.It should be appreciated that described herein, specific examples are only used to explain the present invention, notFor limiting the present invention.
Any feature disclosed in this specification (including abstract and attached drawing) unless specifically stated can be equivalent by otherOr the alternative features with similar purpose are replaced.That is, unless specifically stated, each feature is a series of equivalent or classLike an example in feature.
As shown in Figure 1, a kind of SNS platform authorization requests acquisition methods, method include:
Client sends SNS platform authorization requests;
Server-side receives the SNS platform authorization requests of client transmission, and inquires requested SNS platform configuration information;The configuration information includes OAuth version information, Scope, APPSecret and APPID etc.;
Server-side judges the version that requested SNS platform is based on for OAuth1.0 version according to OAuth version informationOr OAuth2.0 version;
It is executed if version is OAuth1.0 version:
The parameter of request is generated signature signature according to OAuth1.0 standard;
To corresponding api interface request RequestToken, and receive return RequestToken andRequestSecret;
The RequestToken and RequestSecret returned according to interface goes SNS platform to request finallyAccessToken and Token expired time;
It is executed if version is OAuth2.0 version:
AuthCode is requested to corresponding api interface, and receives the AuthCode of return;
SNS platform is gone to request final AccessToken and Token using the AuthCode that corresponding api interface returnsExpired time;
Server-side passes through the acquisition authorization user information of each SNS platform according to the final AccessToken gotApi interface obtain user basic information;The elemental user information includes user's pet name, user's head portrait and User ID etc..
Different API requests, which is combined, according to different OAuth versions links parametric form.
If it is OAuth1.0, request step is as follows:
1. before generating link every time, the parameter of request is generated signature signature according to OAuth1.0 standard;
2. then request RequestToken, api interface returns to RequestToken and RequestSecret;
3. the interim RequestToken and RequestSecret that are returned according to interface go SNS platform to request finallyAccessToken and Token expired time.
If it is OAuth2.0, request step is as follows:
1. requesting AuthCode, api interface returns to AuthCode;
2. going SNS platform to request final AccessToken and Token expired using the AuthCode that api interface returnsTime.
Called different OAuth authentication modes, if it is OAuth1.0, then need to be asked according to this according to different versionsThe parameter asked generates corresponding signature signature.
Required parameter is combined according to OAuth version, then needs to request RequestToken if it is OAuth1.0, andOAuth2.0 then needs to request AuthCode.
Technical solution of the present invention provides SNS platform unified authorization and release information based on OAuth1.0 and OAuth2.0Scheme, conducive to the maintenance and management of later period personnel.Data memory module uses Doctrine, for the interim of API requestToken data are just preserved by the way of temporary file, and use just deletes temporary file (such as OAuth1.0 laterRequestToken, RequestSecret, the AuthCode of OAuth2.0);And the AccessToken of final API request andThe data such as TokenTime are then saved in MySQL database.
In addition, the present invention program used ReactPHP frame realize event-driven, asynchronous execution, Non-Blocking I/O andIt is single thread one process, efficiency of code execution is high.
The HTTP request module of the present invention program all uses Guzzle, this is for post request, Asynchronous Request, upload textPart, proxy requests etc. all become easy processing.
The method also includes, server-sides according to the API RequestToken returned and RequestSecret, orAuthCode combines the OAuth required parameter of corresponding version;According to combined required parameter, corresponding SNS platform authorization is jumped toThe page makes client user log in SNS account to authorize;
Judge whether user agrees to authorize, if agreeing to authorization, records the AccessToken's and Token of API returnExpiration time;If disagreeing authorization, record log, authorization flow terminates.
If disagreeing authorization, the essential information for obtaining client user is no longer gone.
Log module uses Monolog, facilitates the classification for carrying out log and record, and retrospect error message is also rapider.
The method also includes:After client user edits the information for needing to issue, selection needs the authorization SNS issuedPlatform;Server-side needs the information issued to be published to major SNS platform in order according to current task amount, user.
A kind of method using authorized SNS platform release information as shown in Figure 2, is awarded based on above-mentioned SNS platformRequest method is weighed, method includes:
Client user edits the information to be issued and selects authorized SNS platform;
Server-side reads the AccessToken authorized and judges corresponding SNS platform OAuth version;If it isThe platform of OAuth1.0 then generates corresponding signature signature according to the parameter of this request;Request each SNS platformThe api interface of release information submits the text information for needing to issue and uploading pictures data;SNS platform api interface is received to returnPublication whether successful information.
The method also includes recording publication successful information if issued successfully;If publication failure, records mistakeLose log.
A kind of storage equipment provided according to the present invention, is stored with a plurality of instruction, and described instruction includes adding convenient for processorIt carries and handles:
Receive the SNS platform authorization requests of client transmission, and inquires requested SNS platform configuration information;It is described to matchConfidence breath includes OAuth version information, Scope, APPSecret and APPID;
According to OAuth version information judge the version that requested SNS platform is based on for OAuth1.0 version stillOAuth2.0 version;
It is executed if version is OAuth1.0 version:
The parameter of request is generated signature signature according to OAuth1.0 standard;
To corresponding api interface request RequestToken, and receive return RequestToken andRequestSecret;
The RequestToken and RequestSecret returned according to interface goes SNS platform to request finallyAccessToken and Token expired time;
It is executed if version is OAuth2.0 version:
AuthCode is requested to corresponding api interface, and receives the AuthCode of return;
SNS platform is gone to request final AccessToken and Token using the AuthCode that corresponding api interface returnsExpired time;
According to the final AccessToken got, pass through the acquisition authorized client user information of each SNS platformApi interface obtain client user's essential information;The elemental user information includes user's pet name, user's head portrait and userID。
Described instruction further includes loading and handling convenient for processor:According to API return RequestToken andRequestSecret or AuthCode combines the OAuth required parameter of corresponding version;According to combined required parameter, jumpMake client user log in SNS account to corresponding SNS platform authorization page to authorize;
Judge whether user agrees to authorize, if agreeing to authorization, records the AccessToken's and Token of API returnExpiration time;If disagreeing authorization, record log, authorization flow terminates.
Described instruction further includes loading and handling convenient for processor:According to current task amount, client user is neededThe information of publication is published to major SNS platform in order.
Described instruction further includes loading and handling convenient for processor:
The authorized SNS platform of the information to be issued and selection that reading client user edits;According to having authorizedAccessToken and judge corresponding SNS platform OAuth version;If it is the platform of OAuth1.0, then according to this requestParameter generate corresponding signature signature;It requests the api interface of the release information of each SNS platform to be submitted to need to issueText information and uploading pictures data;Receive SNS platform api interface return publication whether successful information.
Described instruction further includes loading and handling convenient for processor:
If issued successfully, publication successful information is recorded;If publication failure, records unsuccessfully log.