Permalink
Browse files

merge gplusnasite/GooglePlusLibrary/ba915b01114ff980da0451909834282fb…

…69443ad
  • Loading branch information...
2 parents 49a9944 + ba915b0 commit 6584455983a020476a716fceeba44f30751542f1 Terushi Arakawa committed Dec 9, 2012
@@ -33,14 +33,12 @@ function streamInitialize(account_id)
do return false end
end
- url = "https://talkgadget.google.com/talkgadget/channel/bind?VER=8&"
+ url = "https://talkgadget.google.com/u/0/talkgadget/_/channel/bind?VER=8&"
url = url .. "clid=" .. clid .. "&gsessionid=" .. gsessionid .. "&prop=homepage&ujidr=TalkGadget" .. talkgadget_number .. "&"
url = url .. "eid&ec=" .. Connection.escapeString("[0,0,0]") .. "&RID=" .. generateRIDValue() .. "&CVER=1&zx=" .. generateZxString() .. "&t=1"
response = connection:httpPost(url, "count=0")
response_body = response:getResponseBody()
- print("res:" .. response_body)
- print("first")
json = connection:convertResponseToJson(response_body)
@@ -67,7 +65,7 @@ function streamInitialize(account_id)
print("Stream connecting ...")
- url = "https://talkgadget.google.com/talkgadget/channel/bind?VER=8&clid=" .. clid .. "&gsessionid=" .. gsessionid .. "&"
+ url = "https://talkgadget.google.com/u/0/talkgadget/_/channel/bind?VER=8&clid=" .. clid .. "&gsessionid=" .. gsessionid .. "&"
url = url .. "prop=homepage&ujidr=TalkGadget" .. talkgadget_number .. "&eid&ec=" .. Connection.escapeString("[0,0,0]") .. "&"
url = url .. "SID=" .. sid .. "&RID=" .. generateRIDValue() .. "&AID=2&zx=" .. generateZxString() .. "&t=1"
@@ -116,8 +114,6 @@ function streamInitialize(account_id)
response = connection:httpPost(url, parameter)
response_body = response:getResponseBody()
- print(response_body)
- print("second")
-- start updating
@@ -44,165 +44,19 @@ function streamLoopUpdate(account_id)
do return false end
end
- connection = Connection()
- connection:setCurrentAccountID(account_id)
-
- url = "https://talkgadget.google.com/talkgadget/channel/bind?VER=8&clid=" .. clid .. "&gsessionid=" .. gsessionid .. "&"
+ url = "https://talkgadget.google.com/u/0/talkgadget/_/channel/bind?VER=8&clid=" .. clid .. "&gsessionid=" .. gsessionid .. "&"
url = url .. "prop=homepage&ujidr=TalkGadget" .. talkgadget_number .. "&eid&ec=" .. Connection.escapeString("[0,0,0]") .. "&"
url = url .. "RID=rpc&SID=" .. sid .. "&CI=0&AID=" .. aid .. "&TYPE=xmlhttp&zx=" .. generateZxString() .. "&t=1"
- response = connection:httpGet(url, false)
-
- response_body = response:getResponseBody()
+ stream_observer = StreamObserver()
- print("response_body:" .. response_body)
+ response = stream_observer:get(account_id, url)
status = response:getStatusCode()
if(status ~= 200) then
print("status:" .. status)
do return false end
end
- json = connection:convertResponseToJson(response_body)
- if(json == nil) then
- print("json == nil")
- end
-
- --print("Json Count:" .. json:count())
-
- for count = 0, json:count(), 1 do
-
- --print("count:" .. count)
- --print("aid" .. aid)
- child_json = json:selectChildNode(count)
-
- if(child_json:isNull()) then
- do return true end
- end
-
- --print("Json:" .. child_json:selectChildNode("[1].[0]"):asString())
- --[[
- if(child_json:selectChildNode("[1].[0]"):asString() == "noop") then
-
- if(aid == "0") then
- print("Connect Error")
- do return false end
- elseif(aid == "1") then
- print("Connect Error")
- do return false end
- elseif(aid == "2") then
- print("Connect Error")
- do return false end
- elseif(aid == "3") then
- print("Connect Error")
- do return false end
- elseif(aid == "4") then
- print("Connect Error")
- do return false end
- elseif(aid == "5") then
- print("Connect Error")
- do return false end
- end
- print("noop aid=" .. aid)
- break
- end
- ]]
- type = child_json:selectChildNode("[1].[1].[1].[0]"):asString()
- --print("type:" .. type)
- if(child_json:selectChildNode("[1].[0]"):asString() == "c") then
- if(type == "ei") then
- print("update gsessionid")
- gsessionid = child_json:selectChildNode("[1].[1].[1].[1]"):asString()
- --print("gsessionid=" .. gsessionid)
-
- aid = aid + 1
- InformationContainer.addInformationByAccountID("aid", aid, account_id)
- break
-
- end
-
- end
- --[[
- if(type == nil) then
- print("type=nil")
- else
- print("type=" .. type)
- end
- ]]
- if(type == "tu") then
-
- -- invalid json string
- valid_json = Utility.convertStringEscapedJson(child_json, "[1].[1].[1].[1]")
- sub_type = valid_json:selectChildNode("[0]"):asString()
-
- if(sub_type == nil) then
- print("sub_type=nil")
- else
- --print("sub_type=" .. sub_type)
-
- if(sub_type == "t.rtu") then
- --print(response_body)
- PostParser.add(valid_json)
- name = valid_json:selectChildNode("[1].[3]"):asString()
- if(isStringNullOrEmpty(name) == nil) then
- --print("sub_type=".. sub_type .. " name == nil")
- else
- --print(account_id .. ":" .. name .. "さんが投稿をポストしたり編集したりしました")
- end
- end
-
- if(sub_type == "t.rtc") then
- --print(response_body)
- CommentParser.add(valid_json)
- name = valid_json:selectChildNode("[1].[1]"):asString()
- if(isStringNullOrEmpty(name) == nil) then
- --print("sub_type=".. sub_type .. " name == nil")
- else
- --print(account_id .. ":" .. name .. "さんがコメントをポストしたり編集したりしました")
- end
- end
-
- if(sub_type == "t.rtd") then
- --print(response_body)
- post_id = valid_json:selectChildNode("[1]"):asString()
- comment_id = valid_json:selectChildNode("[2]"):asString()
-
- if(isStringNullOrEmpty(comment_id) == nil) then
- if(isStringNullOrEmpty(post_id) ~= nil) then
- PostParser.erase(post_id)
- end
- else
- CommentParser.erase(comment_id)
- end
- end
- end
- end
- --[[
- if(type == "ru") then
- print("ru")
-
- name = child_json:selectChildNode("[1].[1].[1].[2]"):asString()
- print("名前:" .. name)
-
- status = child_json:selectChildNode("[1].[1].[1].[15].[1]"):asString()
- print("ステータス:" .. status)
-
- end
- ]]
-
- if(type == "gb") then
- print(account_id .. ":自分がポストとかを投稿したりしました")
- end
-
- aid = aid + 1
- InformationContainer.addInformationByAccountID("aid", aid, account_id)
-
- sleep(10)
-
- end
-
- --sleep(500)
-
do return true end
-
end
@@ -0,0 +1,169 @@
+function streamObserverUpdate(account_id, message)
+
+ print("streamObserverUpdate")
+
+ require("LuaScript/Utility")
+
+ if(isStringNullOrEmpty(account_id) == nil) then
+ print("StringNullOrEmpty(account_id) == nil")
+ do return false end
+ end
+
+ aid = InformationContainer.getInformationByAccountID("aid", account_id)
+
+ if(aid == nil) then
+ print("StringNullOrEmpty(aid) == nil")
+ do return false end
+ end
+
+ print("message:" .. message)
+
+ connection = Connection()
+ json = connection:convertResponseToJson(message)
+ if(json == nil) then
+ print("json == nil")
+ end
+
+ --print("Json Count:" .. json:count())
+
+ for count = 0, json:count(), 1 do
+
+ --print("count:" .. count)
+ --print("aid" .. aid)
+ child_json = json:selectChildNode(count)
+
+ if(child_json:isNull()) then
+ do return true end
+ end
+
+ --print("Json:" .. child_json:selectChildNode("[1].[0]"):asString())
+ --[[
+ if(child_json:selectChildNode("[1].[0]"):asString() == "noop") then
+
+ if(aid == "0") then
+ print("Connect Error")
+ do return false end
+ elseif(aid == "1") then
+ print("Connect Error")
+ do return false end
+ elseif(aid == "2") then
+ print("Connect Error")
+ do return false end
+ elseif(aid == "3") then
+ print("Connect Error")
+ do return false end
+ elseif(aid == "4") then
+ print("Connect Error")
+ do return false end
+ elseif(aid == "5") then
+ print("Connect Error")
+ do return false end
+ end
+ print("noop aid=" .. aid)
+ break
+ end
+ ]]
+ type = child_json:selectChildNode("[1].[1].[1].[0]"):asString()
+ --print("type:" .. type)
+ if(child_json:selectChildNode("[1].[0]"):asString() == "c") then
+ if(type == "ei") then
+ print("update gsessionid")
+ gsessionid = child_json:selectChildNode("[1].[1].[1].[1]"):asString()
+ --print("gsessionid=" .. gsessionid)
+
+ aid = aid + 1
+ InformationContainer.addInformationByAccountID("aid", aid, account_id)
+ break
+
+ end
+
+ end
+ --[[
+ if(type == nil) then
+ print("type=nil")
+ else
+ print("type=" .. type)
+ end
+ ]]
+ if(type == "tu") then
+
+ -- invalid json string
+ valid_json = Utility.convertStringEscapedJson(child_json, "[1].[1].[1].[1]")
+ sub_type = valid_json:selectChildNode("[0]"):asString()
+
+ if(sub_type == nil) then
+ print("sub_type=nil")
+ else
+ --print("sub_type=" .. sub_type)
+
+ if(sub_type == "t.rtu") then
+ --print(response_body)
+ PostParser.add(valid_json)
+ name = valid_json:selectChildNode("[1].[3]"):asString()
+ if(isStringNullOrEmpty(name) == nil) then
+ --print("sub_type=".. sub_type .. " name == nil")
+ else
+ --print(account_id .. ":" .. name .. "さんが投稿をポストしたり編集したりしました")
+ end
+ end
+
+ if(sub_type == "t.rtc") then
+ --print(response_body)
+ CommentParser.add(valid_json)
+ name = valid_json:selectChildNode("[1].[1]"):asString()
+ if(isStringNullOrEmpty(name) == nil) then
+ --print("sub_type=".. sub_type .. " name == nil")
+ else
+ --print(account_id .. ":" .. name .. "さんがコメントをポストしたり編集したりしました")
+ end
+ end
+
+ if(sub_type == "t.rtd") then
+ --print(response_body)
+ post_id = valid_json:selectChildNode("[1]"):asString()
+ comment_id = valid_json:selectChildNode("[2]"):asString()
+
+ if(isStringNullOrEmpty(comment_id) == nil) then
+ if(isStringNullOrEmpty(post_id) ~= nil) then
+ PostParser.erase(post_id)
+ end
+ else
+ CommentParser.erase(comment_id)
+ end
+ end
+ end
+ end
+ --[[
+ if(type == "ru") then
+ print("ru")
+
+ name = child_json:selectChildNode("[1].[1].[1].[2]"):asString()
+ print("名前:" .. name)
+
+ status = child_json:selectChildNode("[1].[1].[1].[15].[1]"):asString()
+ print("ステータス:" .. status)
+
+ end
+ ]]
+
+ if(type == "gb") then
+ print(account_id .. ":自分がポストとかを投稿したりしました")
+ end
+
+ aid = aid + 1
+ InformationContainer.addInformationByAccountID("aid", aid, account_id)
+
+ sleep(100)
+
+ end
+
+ --sleep(500)
+
+ do return true end
+
+end
+
+function sleep(milliseconds)
+ stream_observer = StreamObserver()
+ stream_observer:scriptSleep(milliseconds)
+end
@@ -26,11 +26,6 @@ function generatePVTString()
return ("AMP3u" .. Utility.generateRandomString(89, 89, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_") .. "==")
end
-function sleep(milliseconds)
- stream_connection_impl = StreamConnectionImpl()
- stream_connection_impl:scriptSleep(milliseconds)
-end
-
function makeParameter(parameter_name, parameter)
do return (parameter_name .. "=" .. parameter) end
end
Oops, something went wrong. Retry.

0 comments on commit 6584455

Please sign in to comment.