jianlinwei / google-voice-java

Automatically exported from code.google.com/p/google-voice-java
0 stars 0 forks source link

Added code to delete a message #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Are functions like this one going to be added to the library? Such as, mark, 
star, undelete?

        public String deleteMessage(String msgID) throws IOException
        {
            String out = "";
        StringBuffer calldata = new StringBuffer();

        // POST /voice/inbox/deleteMessages/
        // messages=[messageID]
        // &trash=1
        // &_rnr_se=[pull from page]

        calldata.append("messages=");
        calldata.append(URLEncoder.encode(msgID, enc));
        calldata.append("&trash=1");
        calldata.append("&_rnr_se=");
        calldata.append(URLEncoder.encode(rnrSEE, enc));

        URL callURL = new URL("https://www.google.com/voice/inbox/deleteMessages/");

        URLConnection callconn = callURL.openConnection();
        callconn.setRequestProperty("Authorization","GoogleLogin auth="+authToken);
        callconn.setRequestProperty("User-agent",USER_AGENT);

        callconn.setDoOutput(true);
        OutputStreamWriter callwr = new OutputStreamWriter(callconn
                .getOutputStream());

        callwr.write(calldata.toString());
        callwr.flush();

        BufferedReader callrd = new BufferedReader(new InputStreamReader(
                callconn.getInputStream()));

        String line;
        while ((line = callrd.readLine()) != null) {
            out += line + "\n\r";

        }

        callwr.close();
        callrd.close();

        if (out.equals("")) {
            throw new IOException("No Response Data Received.");
        }

        return out;
        }

Original issue reported on code.google.com by monstrf...@gmail.com on 25 Sep 2010 at 4:42

GoogleCodeExporter commented 9 years ago
A few more functions to add.

/**
     * Gets the Voicemail page raw source code.
     *
     * @return the Voicemail
     * @throws IOException
     *             Signals that an I/O exception has occurred.
     */
    public String getVoicemail() throws IOException {
        return get(voicemailURLString);
    }

    public String getVoicemailPage(int page) throws IOException {
        return get(voicemailURLString,page);
    }

        /**
     * Downloads a voicemail
     *
         * @param id of the voicemail to download
     * @return byte output stream
     * @throws IOException
     *             Signals that an I/O exception has occurred.
     */
        public ByteArrayOutputStream downloadVoicemail(String msgID) throws IOException
        {
           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

           try
           {
               URL u = new URL (voicemailDownloadURLString + msgID);
               HttpURLConnection huc = (HttpURLConnection)u.openConnection () ;
               huc.setRequestProperty("Authorization", "GoogleLogin auth="+authToken);
               huc.setRequestProperty("User-agent", USER_AGENT);
               huc.setRequestMethod ("GET");
               huc.connect() ;
               InputStream is = huc.getInputStream();

               if(huc.getResponseCode() == HttpURLConnection.HTTP_OK)
               {
                   byte[] buffer = new byte [4096];
                   int bytes = 0;

                   while(true)
                   {
                       bytes = is.read(buffer);
                       if(bytes <= 0)
                           break;
                       outputStream.write(buffer, 0, bytes);
                   }

                   outputStream.flush();
               }

               huc.disconnect ();

               return outputStream;
           }
           catch(IOException e)
           {
               System.out.println ( "Exception\n" + e ) ;
           }

           return null;
        }

Original comment by monstrf...@gmail.com on 26 Sep 2010 at 6:12

GoogleCodeExporter commented 9 years ago
Monstrfolk,

Would you like to be added as a committer?  Is your email monstrfolk@gmail.com? 
 Feel free to email me directly to discuss it

-Joseph

Original comment by malone.j...@gmail.com on 26 Sep 2010 at 9:46

GoogleCodeExporter commented 9 years ago
sounds good to me. I can add onto this. I have a php google voice api that I 
have built from many web sources. Basically I am just converting my php api to 
java.

Original comment by monstrf...@gmail.com on 26 Sep 2010 at 9:53

GoogleCodeExporter commented 9 years ago
oh...i can't seem to figure out where I can get your email from this website.

Original comment by monstrf...@gmail.com on 26 Sep 2010 at 9:54

GoogleCodeExporter commented 9 years ago
It is malone dot joseph at gmail

Original comment by malone.j...@gmail.com on 26 Sep 2010 at 11:02

GoogleCodeExporter commented 9 years ago
google voice is having problems with sign on subscribed users for the BB Bold 
9000 with updated OS. It is somehow reading subscribed users as unsubscribed. I 
do not understand why. 

Original comment by shanekyr...@gmail.com on 29 Sep 2010 at 2:33

GoogleCodeExporter commented 9 years ago
I've added this to monstrfolk because I see he's a committer now even though I 
haven't seen these functions added yet.

Original comment by liquid...@gmail.com on 6 Jan 2011 at 2:50

GoogleCodeExporter commented 9 years ago
Liquid, what do you want me to add or fix?

Original comment by monstrf...@gmail.com on 12 Jan 2011 at 11:23

GoogleCodeExporter commented 9 years ago
Hey guys,

I'm working on some scripting for an on-duty phone system that I maintain, and 
I have been working with google-voice-java for the most part.

I see that you guys have been working on the delete function (as based on my 
reading in this thread), but I couldn't find the function in the documentation.

Is there some reading that I could be doing on how to use this to delete all of 
the sms messages in an accounts inbox?

Thanks for any help =)

Original comment by B.C.Sto...@gmail.com on 12 Apr 2011 at 9:23

GoogleCodeExporter commented 9 years ago
monstrfolk, I was going to let you add and test the functions you added above 
and just commit them. 

B.C.,

These aren't in the repository yet. You should be able to add them locally and 
compile the library yourself though.

Original comment by liquid...@gmail.com on 12 Apr 2011 at 10:21

GoogleCodeExporter commented 9 years ago
those functions should be already be added. i committed them months ago.

comment #9. you can create a function to delete all messages by querying each 
page of messages then deleting each message on every page.

I have also built a fully functioning parser that works for Voicemails and SMS 
messages.

It could be integrated into the current project if people are interested.

Original comment by monstrf...@gmail.com on 27 Apr 2011 at 5:50

GoogleCodeExporter commented 9 years ago
Monstrfolk, I am assuming you completed Voicemail SMS parser commits???  

Can I close off this issue?

Original comment by malone.j...@gmail.com on 3 Feb 2012 at 3:40

GoogleCodeExporter commented 9 years ago
Monstrfolk, thank you for adding parsers for these functions. I'm checking them 
out now, and will using them in my project that I am currently working on.

Original comment by bait...@gmail.com on 14 Feb 2012 at 8:59

GoogleCodeExporter commented 9 years ago
I have confirmed that deleting SMS messages works correctly; I would think that 
it is safe to close this one.

Original comment by bait...@gmail.com on 15 Feb 2012 at 8:29

GoogleCodeExporter commented 9 years ago

Original comment by malone.j...@gmail.com on 25 Mar 2012 at 2:05