aaronpk / Google-Voice-PHP-API

Unmaintaned: Please do not contact me with support requests. If this no longer works, it's because Google Voice changed their systems. I will accept pull requests that fix things. Check out http://twilio.com for a much better API for sending and receiving SMSs.
Other
228 stars 108 forks source link

It works locally and fails remotely #17

Open MotionDesignStudio opened 10 years ago

MotionDesignStudio commented 10 years ago

This is the error I am receiving.

Fatal error: Uncaught exception 'Exception' with message 'Could not log in to Google Voice with username: XXXXX@hotmail.com' in /mnt/stor1-wc2-dfw1/416498/627339/php.mo-de.net/web/content/farse/Google-Voice-PHP-API-master/GoogleVoice.php:69 Stack trace: #0 /mnt/stor1-wc2-dfw1/416498/627339/php.mo-de.net/web/content/farse/Google-Voice-PHP-API-master/GoogleVoice.php(204): GoogleVoice->_logIn() #1 /mnt/stor1-wc2-dfw1/416498/627339/php.mo-de.net/XXX/XXX/XXX/XXXX.php(20): GoogleVoice->getUnreadSMS() #2 {main} thrown in /mnt/stor1-wc2-dfw1/416498/627339/php.mo-de.net/XXX/XXXX/XXXXX/Google-Voice-PHP-API-master/GoogleVoice.php on line 69

DanielMarquard commented 10 years ago

I had this problem today also, except I didn't test locally. If you add print_r($html); to the _logIn() function, you'll probably get a page asking you to verify your identity (see attached screenshot). You won't be able to submit the form, though, so you'll have to try something else. Maybe try logging in with links or elinks. If this is your problem, it would make sense that it works locally but not remotely.

Hope this helps! I will be forking this to add my own functions to it, so I might have to add a few lines to handle submitting the recovery email for verification. I'll reply here if I can get the author to merge my updates.

screenshot-20140422-1029

DanielMarquard commented 10 years ago

@lindylex, can you please test my fork before I submit a pull request? Just pass GoogleVoice() your Gmail's recovery email address as a third argument. Let me know how it works for you.

https://github.com/danielmarquard/Google-Voice-PHP-API

MotionDesignStudio commented 10 years ago

Danielmarquard, you are awesome. I was dreading the idea of spending hours trying to figure this out. I just do not have enough time.

I am not home. I will test this later today. I seriously hope this works. I will give you credit at the url where I created a project using this code.

Thanks, Lex

MotionDesignStudio commented 10 years ago

I added the following to permanently delete a message. I have never requested a merge or submitted my changes before. I will give it a try.

/**
 * Delete permanently a message or conversation.
 * @param $message_id The ID of the conversation to delete.
 */

public function deleteForever($message_id) {
    $this->_logIn();

    curl_setopt($this->_ch, CURLOPT_URL, 'https://www.google.com/voice/b/0/inbox/deleteForeverMessages/');
    curl_setopt($this->_ch, CURLOPT_POST, TRUE);
    curl_setopt($this->_ch, CURLOPT_POSTFIELDS, array(
        '_rnr_se' => $this->_rnr_se,
        'messages' => $message_id,
        'trash' => 1
    ));

    curl_exec($this->_ch);
}

I added the following from above, above this line: " public function dom_dump($obj) {"

Use it like this to permanently delete a message. $gv->deleteForever($s->id);

MotionDesignStudio commented 10 years ago

I tested it locally and it works fine. My hosting company changed something in their settings disabling my ability to upload to my website. Once I have access I will upload to test.

MotionDesignStudio commented 10 years ago

Danielmarquard ,

I receive this error testing it remotely:

Fatal error: Uncaught exception 'Exception' with message 'Could not log in to Google Voice with username: XXX@gmail.com' in /XXX/XXX/php.mo-de.net/XXX/Google-Voice-PHP-API-master/GoogleVoice.php:88 Stack trace: #0 /XXX/XXXX/php.mo-de.net/XXXX/Google-Voice-PHP-API-master/GoogleVoice.php(223): GoogleVoice->_logIn() #1 /XXXXXXX/php.mo-de.net/XXXX.php(27): GoogleVoice->getUnreadSMS() #2 {main} thrown in /XXXXXX/php.mo-de.net/XXXX/Google-Voice-PHP-API-master/GoogleVoice.php on line 88

DanielMarquard commented 10 years ago

Hey @lindylex. Sorry for my delay. :)

Can you add print_r($html) to that exception message in GoogleVoice.php? That will display the page that the script fails on. That will be helpful to both of us.

boombatower commented 10 years ago

Just a heads up this approach needs to updated as

value="RecoveryEmailChallenge"

no longer exists in the page and the form appears to differ as well.

MotionDesignStudio commented 9 years ago

Boombatower and DanielMarquad, I printed out the html error where the exception error is located and this is what I see. It looks like Google wants me prove what city I login from. It is asking me some secirity question.

This is the line I modified to display the error.

"throw new Exception("Could not log in to Google Voice with username: PRINT HTML >> ". print_r($html)." << PRINT HTML". $this->_login);"

May you help me solve this please?
error

http://mo-de.net/d/error.png

Sorry for the huge delay. I was in hosting company hell for 7 months.

MotionDesignStudio commented 9 years ago

[ Solution Solved ]

The problem: Google does not like less secure applications to have access to your account. When these applications try to login additional verification steps are needed. A way to get pass this is to decrease the level of security by doing the following.

That solved it for me.

Thanks for all the help, until next time.

[ This is what I created if anyone is interested in playing with it. ]

http://mo-de.net/farce/

sandhibaljeet commented 8 years ago

hello DanielMarquard, i found this today and this is very nice n helpful, but i have some issue with

Fatal error: Uncaught exception 'Exception' with message 'Could not parse for GALX token' in /home/anjali09/public_html/sms2/GoogleVoice.php:48 Stack trace: #0 /home/anjali09/public_html/sms2/GoogleVoice.php(110): GoogleVoice->_logIn() #1 /home/anjali09/public_html/sms2/example.php(13): GoogleVoice->callNumber('9530519517', '5558675309', 'mobile') #2 {main} thrown in /home/anjali09/public_html/sms2/GoogleVoice.php on line 48 please tell me about this and a solution.

marallyn commented 8 years ago

Look at https://github.com/xenth/Google-Voice-PHP-API It is a forked version of this repository that parses the google login page using a more robust dom method. Also look at https://github.com/marallyn/Google-Voice-PHP-API which is a fork of xenth's fork that adds a few more functions and abstractions.

DavidBerdik commented 6 years ago

I wrote a script that uses this API set up as a cron job to run once a minute, and while it works for a little while, it seems that after enough login attempts, Google starts throwing captchas in to the mix, which causes trouble logging in. Does anyone have a solution to that, or does change account settings to allow less secure apps fix the problem?

daviddietz-zz commented 6 years ago

@DavidBerdik Give this a try: https://accounts.google.com/b/0/DisplayUnlockCaptcha

DavidBerdik commented 6 years ago

@daviddietz-zz I haven't quite figured out what the link does, but I did push the "Continue" button.

daviddietz-zz commented 6 years ago

@DavidBerdik Unlock Gmail for a New Email Program or Service: To allow a new email program that Gmail has blocked as suspicious access to your account:

1. Have the email program or service (cron job) that has failed to access your Gmail account ready. Important: If you use 2-step authentication with your Gmail account (https://www.lifewire.com/secure-your-gmail-account-with-password-and-phone-authentication-1171958), make sure you create an application password for the new client (https://www.lifewire.com/get-a-password-to-access-gmail-by-pop-imap-2-1171882).

2. Visit the Allow access to your Google account page at Google. (https://accounts.google.com/DisplayUnlockCaptcha) Note: Log in to the desired Gmail account if prompted.

3. Click Continue.

4. Within 10 minutes of clicking "Continue," have the previously blocked email service or program (your cron job) check for new messages.

DavidBerdik commented 6 years ago

@daviddietz-zz Okay thank you. I had to change my script to use a new Google account, and within the first 24 hours of doing so, I had to use this twice, but since then, it appears to be working without any interruptions.