Created
March 21, 2013 15:00
-
-
Save kmod-midori/5213706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request=require('request'); | |
exports.client_secret='q-tA1vMJhkoeoucVH7NfvryX'; | |
exports.client_id='545553600905.apps.googleusercontent.com'; | |
exports.app_version=13196; | |
exports.request=function(access,data,uid,callback){ | |
if(typeof data == 'string'){ | |
//refresh token | |
var qs=require('querystring'); | |
var option={ | |
url:'https://accounts.google.com/o/oauth2/token', | |
method:'POST', | |
encoding:'utf-8', | |
headers:{ | |
'User-Agent':'gtm-oauth2 com.google.GooglePlus/4.2.0', | |
'Content-Type':'application/x-www-form-urlencoded', | |
'Accept-Language':'zh-cn' | |
}, | |
//proxy:'http://127.0.0.1:8888', | |
form:{ | |
client_id:this.client_id, | |
client_secret:this.client_secret, | |
grant_type:'refresh_token', | |
refresh_token:data | |
} | |
}; | |
}else{ | |
if(typeof data.length !='undefined'){ | |
var body=[]; | |
for(var i in data){ | |
data[i].params.commonFields={}; | |
data[i].params.commonFields.appVersion=this.app_version; | |
if(typeof uid !='undefined')data[i].params.commonFields.effectiveUser=uid; | |
data[i].apiVersion='v2'; | |
data[i].jsonrpc='2.0' | |
body.push(data[i]); | |
} | |
}else{ | |
var body=data; | |
body.params.commonFields={}; | |
body.params.commonFields.appVersion=this.app_version; | |
if(typeof uid !='undefined')body.params.commonFields.effectiveUser=uid; | |
body.apiVersion='v2'; | |
body.jsonrpc='2.0'; | |
} | |
var body=JSON.stringify(body); | |
var option={ | |
url:'https://www.googleapis.com/rpc?prettyPrint=false', | |
method:'POST', | |
encoding:'utf-8', | |
body:body, | |
//proxy:'http://127.0.0.1:8888', | |
headers:{ | |
'Accept':'application/json-rpc', | |
'Accept-Language':'zh-cn', | |
'User-Agent':'Mozilla/5.0 (iPad1,1; U; CPU iPhone OS 5_1_1 like Mac OS X; zh_CN) com.google.GooglePlus/13196 (KHTML, like Gecko) Mobile/K48AP (gzip)', | |
'Authorization':access | |
} | |
}; | |
} | |
request(option,function(err,rep,body){ | |
if(err){callback(err);return;} | |
var body=JSON.parse(body); | |
if(typeof body.error !='undefined'){ | |
err=body.error.message; | |
} | |
callback(err,body); | |
}); | |
} | |
exports.user={ | |
getMobileSettings:function(gtl){ | |
return { | |
id:'gtl_'+gtl, | |
method:'plusi.ozinternal.getmobilesettings', | |
params:{} | |
}; | |
} | |
}; | |
exports.activities={ | |
getById:function(gtl,id){ | |
return { | |
id:'gtl_'+gtl, | |
method:'plusi.ozinternal.getactivitiesbyid', | |
params:{ | |
activityId:[id], | |
embedOptions:{ | |
includeType:["PLAY_MUSIC_TRACK","PLACE","PLUS_PHOTO_ALBUM","PLACE_REVIEW","PLUS_PHOTOS_ADDED_TO_COLLECTION","SQUARE_INVITE","CHECKIN","VIDEO_OBJECT","PLUS_EVENT","APP_INVITE","EMOTISHARE","SQUARE","HANGOUT_CONSUMER","PLUS_PHOTO","PLAY_MUSIC_ALBUM","THING","WEB_PAGE","HANGOUT_BROADCAST"] | |
}, | |
fieldRequestOptions:{ | |
includeEmbedsData:true | |
} | |
} | |
}; | |
}, | |
post:function(gtl,content,target){ | |
if(typeof target.length =='undefined')var target=[{groupType:'PUBLIC'}]; | |
return { | |
id:'gtl_'+gtl, | |
method:'plusi.ozinternal.postactivity', | |
params:{ | |
sharingRoster:{ | |
sharingTargetId:target | |
}, | |
updateSegments:{ | |
segments:segments | |
}, | |
externalId:parseInt(Math.random()*(7000000000000-1000000000000+1)+1000000000000).toString()+'_'+parseInt(Math.random()*(5000000000-1000000000+1)+1000000000).toString() | |
} | |
}; | |
}, | |
comment:function(gtl,text,oid){ | |
return { | |
id:'gtl_'+gtl, | |
method:'plusi.ozinternal.postcomment', | |
params:{ | |
activityId:oid, | |
clientId:parseInt(Math.random()*(7000000000-1000000000+1)+1000000000), | |
commentText:text, | |
contentFormat:'SEGMENTS', | |
creationTimeMs:new Date().getTime() | |
} | |
}; | |
} | |
}; | |
exports.notifications={ | |
get:function(gtl,max){ | |
if(typeof max !='number')var max=20; | |
return { | |
id:'gtl_'+gtl, | |
method:'plusi.ozinternal.getnotifications', | |
params:{ | |
maxResults:max, | |
notificationsResponseOptions:{ | |
includeFullActorDetails:false, | |
numPhotoEntities:50, | |
includeFullEntityDetails:true, | |
includeFullRootDetails:false | |
}, | |
typeGroupToFetch:[ | |
"BASELINE_STREAM" | |
//"BASELINE_CIRCLE", | |
//"BASELINE_SQUARE" | |
], | |
summarySnippets:['PLAIN'] | |
} | |
}; | |
}, | |
updateLastReadTime:function(gtl,time){ | |
return { | |
id:'gtl_'+gtl, | |
method:'plusi.ozinternal.updatenotificationslastreadtime', | |
params:{ | |
timeMs:time | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment