Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

It works locally and fails remotely #17

Open
MotionDesignStudio opened this issue Apr 14, 2014 · 17 comments
Open

It works locally and fails remotely #17

MotionDesignStudio opened this issue Apr 14, 2014 · 17 comments

Comments

@MotionDesignStudio
Copy link

This is the error I am receiving.

Fatal error: Uncaught exception 'Exception' with message 'Could not log in to Google Voice with username: [email protected]' 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
Copy link

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
Copy link

@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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

Danielmarquard ,

I receive this error testing it remotely:

Fatal error: Uncaught exception 'Exception' with message 'Could not log in to Google Voice with username: [email protected]' 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
Copy link

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
Copy link

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
Copy link
Author

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
Copy link
Author

[ 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
Copy link

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
Copy link

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
Copy link

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
Copy link

@DavidBerdik
Copy link

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

@daviddietz-zz
Copy link

daviddietz-zz commented Jul 26, 2018

@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
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants