{"action":"created","issue":{"url":"https://api.github.com/repos/dPhoeniixx/Textnow-API/issues/4","repository_url":"https://api.github.com/repos/dPhoeniixx/Textnow-API","labels_url":"https://api.github.com/repos/dPhoeniixx/Textnow-API/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/dPhoeniixx/Textnow-API/issues/4/comments","events_url":"https://api.github.com/repos/dPhoeniixx/Textnow-API/issues/4/events","html_url":"https://github.com/dPhoeniixx/Textnow-API/issues/4","id":295887964,"number":4,"title":"TextNow make message read.","user":{"login":"diashkhan","id":33514587,"avatar_url":"https://avatars2.githubusercontent.com/u/33514587?v=4","gravatar_id":"","url":"https://api.github.com/users/diashkhan","html_url":"https://github.com/diashkhan","followers_url":"https://api.github.com/users/diashkhan/followers","following_url":"https://api.github.com/users/diashkhan/following{/other_user}","gists_url":"https://api.github.com/users/diashkhan/gists{/gist_id}","starred_url":"https://api.github.com/users/diashkhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diashkhan/subscriptions","organizations_url":"https://api.github.com/users/diashkhan/orgs","repos_url":"https://api.github.com/users/diashkhan/repos","events_url":"https://api.github.com/users/diashkhan/events{/privacy}","received_events_url":"https://api.github.com/users/diashkhan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-09T14:26:20Z","updated_at":"2018-02-09T19:07:55Z","closed_at":null,"author_association":"NONE","body":"You have done a great work to be honest, just Awesome. Can you please add an extra piece of coding which will make a particular text from unread to read. Thank you in advance! "},"comment":{"url":"https://api.github.com/repos/dPhoeniixx/Textnow-API/issues/comments/364529406","html_url":"https://github.com/dPhoeniixx/Textnow-API/issues/4#issuecomment-364529406","issue_url":"https://api.github.com/repos/dPhoeniixx/Textnow-API/issues/4","id":364529406,"user":{"login":"blacksector","id":6626533,"avatar_url":"https://avatars3.githubusercontent.com/u/6626533?v=4","gravatar_id":"","url":"https://api.github.com/users/blacksector","html_url":"https://github.com/blacksector","followers_url":"https://api.github.com/users/blacksector/followers","following_url":"https://api.github.com/users/blacksector/following{/other_user}","gists_url":"https://api.github.com/users/blacksector/gists{/gist_id}","starred_url":"https://api.github.com/users/blacksector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blacksector/subscriptions","organizations_url":"https://api.github.com/users/blacksector/orgs","repos_url":"https://api.github.com/users/blacksector/repos","events_url":"https://api.github.com/users/blacksector/events{/privacy}","received_events_url":"https://api.github.com/users/blacksector/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T19:07:55Z","updated_at":"2018-02-09T19:07:55Z","author_association":"NONE","body":"@diashkhan \r\nI added my own function inside of textnow.py and it looks like this:\r\n```python\r\ndef messageRead(self, msg):\r\n  if self.Login == False:\r\n          return False\r\n\r\n  contactValue = msg[\"contact_value\"]\r\n  msgId = msg[\"id\"]\r\n\r\n  node = 'users/%s/conversations/%s'%(self.username, contactValue)\r\n  query = '?client_type=TN_ANDROID&client_id=%s&latest_message_id=%s'%(self.Login, msgId)\r\n\r\n  msgData = OrderedDict([\r\n          ('read', True)\r\n          ])\r\n  jsonData = self.genJson(msgData)\r\n  sign = self.genSignature(\"PATCH\", node, query+jsonData)\r\n  req = self.sendReq(\"PATCH\", \"%s%s%s\"%(self.API_URL, node, query), sign, jsonData)\r\n\r\n  return req\r\n```\r\n\r\nwhen you call it from your main program call it like this:\r\n\r\n```python\r\nTN = textnow.Textnow(EMAIL, PASSWORD)\r\nTN.login()\r\nTN.messageRead(x)\r\n```\r\nthe variable `x` is a single element from the TN.getMessages()[\"messages\"]. Here is a sample of how it looks:\r\n```python\r\n{u'username': u'<REDACTED>', u'e164_contact_value': u'<REDACTED>', u'contact_type': 2, u'read': True, u'message': u\"Hello World\", u'message_direction': 2, u'conversation_filtering': {u'first_time_contact': False, u'previous_number_owner_contact': None}, u'date': u'2018-02-09T18:20:20Z', u'contact_name': u'', u'message_type': 1, u'id': 20087166090L, u'contact_value': u'<REDACTED>'}\r\n```\r\n\r\nSome more sample code to make it work in case I wasn't entirely clear:\r\n\r\n```python\r\n\r\nTN = textnow.Textnow(EMAIL, PASSWORD)\r\nTN.login()\r\n\r\n\r\n# Last known message id\r\nlastMessageId = 1\r\n\r\nwhile True:\r\n    try:\r\n        messages = TN.getMessages(lastMessageId)\r\n        # Iterate through messages from response\r\n        for x in messages[\"messages\"]:\r\n            # Unread and incoming message:\r\n            if x[\"read\"] == False and x[\"message_direction\"] == 1:\r\n                # Mark message as read.\r\n                TN.messageRead(x)\r\n\r\n                number = str(x[\"e164_contact_value\"])\r\n                \r\n                print \"Message from \" + number\r\n\r\n            # Set last message id - this is sort of a pagination mechanism\r\n            lastMessageId = int(x[\"id\"])\r\n\r\n    except:\r\n        print \"Something went wrong! :(\"\r\n```\r\n\r\nThe function `TN.messageRead()` doesn't return anything valuable or of use. I haven't exactly made it so that it is user friendly and didn't think I would have been releasing it. So modify it to your own use case."}}
{"actor":{"display_login":"blacksector"}}