GithubHelp home page GithubHelp logo

aaronpk / google-voice-php-api Goto Github PK

View Code? Open in Web Editor NEW
226.0 33.0 108.0 32 KB

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.

License: Other

PHP 100.00%

google-voice-php-api's Introduction

No Maintenance Intended

Google Voice PHP API

An API to interact with Google Voice using PHP.

Currently the API can place calls, cancel previously placed calls, send and receive SMS messages, add a note to or remove a note from a message or voicemail, mark a message or voicemail as read or unread, and download transcriptions and/or MP3 files of voicemail. Feel free to implement new functionality and send me your changes so I can incorporate them into this library!

getUnreadSMS, getReadSMS, getUnreadVoicemail, and getReadVoicemail all return an array of JSON objects. Each object has the following attributes, example values included:

$msg->id = c3716aa447a19c7e2e7347f443dd29091401ae13
$msg->phoneNumber = +15555555555
$msg->displayNumber = (555) 555-5555
$msg->startTime = 1359918736555
$msg->displayStartDateTime = 2/3/13 5:55 PM
$msg->displayStartTime = 5:55 PM
$msg->relativeStartTime = 5 hours ago
$msg->note = 
$msg->isRead = true
$msg->isSpam = false
$msg->isTrash = false
$msg->star: = alse
$msg->messageText = Hello, cellphone.
$msg->labels = [sms,all]
$msg->type = 11
$msg->children = 

Note: Receiving SMSs and voicemails is mostly unnecessary via this API since Google now allows SMSs to be forwarded to an email address. It is a better idea to parse those incoming emails with a script.

SMS and Voice Integration

For better SMS and voice integration with your web app, check out Tropo at tropo.com. Tropo is free for development, and you will get better results than using unsupported Google Voice API calls.

Check out some sample apps built with Tropo

Disclaimer

This code is provided for educational purposes only. This code may stop working at any time if Google changes their login mechanism or their web pages. You agree that by downloading this code you agree to use it solely at your own risk.

License

Copyright 2009 by Aaron Parecki http://aaronparecki.com

See LICENSE

google-voice-php-api's People

Contributors

aaronpk avatar andkore avatar citbr avatar jamenlang avatar jimvernon avatar rhodey avatar xenth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-voice-php-api's Issues

Google is at it again

With Google hitting the the new oauth portal hard, I managed to avoid a ton of scraping issues by changing the user agent to back to Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0),

too bad I can't force curl to say I DON'T DO JAVASCRIPT SORRY

"May need to change scraping" Error

This morning, I started receiving the following error when trying to use this API with my texting script. For privacy, I have stripped out some parts of the error, marking them as "<REDACTED>." Note that the "Passwd" entry in the array is empty, and not marked, meaning that the password was never even received (read: I did not remove the password and forget to mark having done so when posting this. It was never there.). Has anyone else started seeing this as well?

Could not log in to Google Voice with username: <REDACTED>

May need to change scraping.  Here are the inputs from the page:
array (
  'Page' => 'PasswordSeparationSignIn',
  '' => '',
  'gxf' => '<REDACTED>',
  'continue' => 'https://www.google.com/voice/b/0/redirection/voice',
  'followup' => 'https://www.google.com/voice/b/0/redirection/voice',
  'service' => 'grandcentral',
  'flowName' => 'GlifWebSignIn',
  'ProfileInformation' => '<REDACTED>',
  'SessionState' => '<REDACTED>',
  '_utf8' => 'โ˜ƒ',
  'bgresponse' => 'js_disabled',
  'Email' => '<REDACTED>',
  'Passwd' => '',
  'logintoken' => '<REDACTED>',
  'url' => '<REDACTED>',
  'logintoken_audio' => '<REDACTED>',
  'url_audio' => '<REDACTED>',
  'logincaptcha' => '',
  'signIn' => 'Sign in',
  'PersistentCookie' => 'yes',
)
PHP Fatal error:  Uncaught Exception: Could not log in to Google Voice with username: <REDACTED>
Look at error log for detailed input information.
 in /home/<REDACTED>/Desktop/<REDACTED>/GoogleVoice.php:75
Stack trace:
#0 /home/<REDACTED>/Desktop/<REDACTED>/GoogleVoice.php(160): GoogleVoice->_logIn()
#1 /home/<REDACTED>/Desktop/<REDACTED>/texter.php(6): GoogleVoice->sendSMS('<REDACTED>', '<REDACTED>')
#2 {main}
  thrown in /home/<REDACTED>/Desktop/<REDACTED>/GoogleVoice.php on line 75

Could not parse for GALX token

When trying to login and send a test text message, an exception is thrown:

Uncaught exception 'Exception' with message 'Could not parse for GALX token'

Not sure if this is just happening to me or is happening with other users.

BROKEN!!!

I've been using this for months without any issues. Google just updated their security for "voice mail" and it seems to have broken the programming. Anyone have a solution or experience the same problem?

It works locally and fails remotely

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

Getting a blank screen on VM

I am getting a blank screen after the get voice mail line:
$voicemails = $gv->getNewVoicemail();

I put a:
echo "test";
directly after that line and I dont get that either. All of this as part of example.php.

I also marked one of my vm transcripts as unread and put it there, and still got no joy. Seems it isn't parsing vm correctly.

Login doesn't work

Currently, i am getting below error in Google login,

Fatal error: Uncaught Exception: Could not log in to Google Voice with username: [email protected] Look at error log for detailed input information. in /Applications/MAMP/htdocs/Google-Voice-PHP-API-master/GoogleVoice.php:75 Stack trace: #0 /Applications/MAMP/htdocs/Google-Voice-PHP-API-master/GoogleVoice.php(160): GoogleVoice->_logIn() #1 /Applications/MAMP/htdocs/Google-Voice-PHP-API-master/example.php(17): GoogleVoice->sendSMS('+XXX XXX XXXX', 'Sending a messa...') #2 {main} thrown in /Applications/MAMP/htdocs/Google-Voice-PHP-API-master/GoogleVoice.php on line 75

I tried to debug the lib and print cURL request and found "Javascript doesn't support error"
Screenshot 2019-05-22 at 3 19 28 PM

however javascript is enabled in Browser. Also, two factor authentication is disabled.

Please help me to debug the issue.

Did he fall off the face of the earth?

Where did he go? google still has no official API and the changes talked about here have not been done to the API. This is really sad. If you download the code and make the changes talked about in the Issues section then the API works great!

Something Seems a Bit Different About the Way You're Trying to Sign in

I'm running into a new verification step. Any ideas about getting around this?

Verify it's you

Something seems a bit different about the way you're trying to sign in. Complete the step below to let us know it's you and not someone pretending to be you. Learn more.

Select a verification method

Enter a phone number
Receive via:
a text message (SMS)
an automated phone call
Standard text messaging rates apply.

Tell us the city you usually sign in from
Having trouble? Ask Google for help to get back into your account.

Suggested additions to GoogleVoice.php

Two suggested additions/revision. The first removes references to Gizmo (RIP) and allows canceling a call in progress (replaces existing callNumber function and adds cancelCall function):

    /**
     * Place a call to $number connecting first to $fromNumber.
     * @param $number The 10-digit phone number to call (formatted with parens and hyphens or none).
     * @param $fromNumber The 10-digit number on your account to connect the call (no hyphens or spaces).
     * @param $phoneType (mobile, work, home) The type of phone the $fromNumber is. The call will not be connected without this value. 
     */
    public function callNumber($number, $from_number, $phone_type = 'mobile') {
        $types = array(
            'mobile' => 2,
            'work' => 3,
            'home' => 1
        );

        // Make sure phone type is set properly.
        if(!array_key_exists($phone_type, $types))
            throw new Exception('Phone type must be mobile, work, or home');

        // Login to the service if not already done.
        $this->_logIn();

        // Send HTTP POST request.
        curl_setopt($this->_ch, CURLOPT_URL, 'https://www.google.com/voice/call/connect/');
        curl_setopt($this->_ch, CURLOPT_POST, TRUE);
        curl_setopt($this->_ch, CURLOPT_POSTFIELDS, array(
            '_rnr_se' => $this->_rnr_se,
            'forwardingNumber' => '+1'.$from_number,
            'outgoingNumber' => $number,
            'phoneType' => $types[$phone_type],
            'remember' => 0,
            'subscriberNumber' => 'undefined'
            ));
        curl_exec($this->_ch);
    }

    /**
     * Cancel a call to $number connecting first to $fromNumber.
     * @param $number The 10-digit phone number to call (formatted with parens and hyphens or none).
     * @param $fromNumber The 10-digit number on your account to connect the call (no hyphens or spaces).
     * @param $phoneType (mobile, work, home) The type of phone the $fromNumber is. The call will not be connected without this value. 
     */
    public function cancelCall($number, $from_number, $phone_type = 'mobile') {
        $types = array(
            'mobile' => 2,
            'work' => 3,
            'home' => 1
        );

        // Make sure phone type is set properly.
        if(!array_key_exists($phone_type, $types))
            throw new Exception('Phone type must be mobile, work, or home');

        // Login to the service if not already done.
        $this->_logIn();

        // Send HTTP POST request.
        curl_setopt($this->_ch, CURLOPT_URL, 'https://www.google.com/voice/call/cancel/');
        curl_setopt($this->_ch, CURLOPT_POST, TRUE);
        curl_setopt($this->_ch, CURLOPT_POSTFIELDS, array(
            '_rnr_se' => $this->_rnr_se,
            'forwardingNumber' => '+1'.$from_number,
            'outgoingNumber' => $number,
            'phoneType' => $types[$phone_type],
            'remember' => 0,
            'subscriberNumber' => 'undefined'
            ));
        curl_exec($this->_ch);
    }

The next suggested addition allows getting the MP3 file of a Google Voice voicemail, assuming you know the id of the voicemail:

    /**
     * Get MP3 of a Google Voice Voicemail.
     */
    public function getVoicemailMP3($message_id) {
        // Login to the service if not already done.
        $this->_logIn();

        // Send HTTP POST request.
        curl_setopt($this->_ch, CURLOPT_URL, "https://www.google.com/voice/media/send_voicemail/$message_id/");
        curl_setopt($this->_ch, CURLOPT_POST, FALSE);
        curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, TRUE);
        $results = curl_exec($this->_ch);

        return $results;
    }

Login doesn't work any longer

When trying to use the API - I get the following error:
Fatal error: Uncaught exception 'Exception' with message 'Could not log in to Google Voice with username: [email protected]' in /homepages/44/d157697781/htdocs/GoogleVoice.php:66 Stack trace: #0 /homepages/44/d157697781/htdocs/GoogleVoice.php(105): GoogleVoice->_logIn() #1 /homepages/44/d157697781/htdocs/TEST-autotexting.php(18): GoogleVoice->sendSMS('2062289034', 'Testing Texting...') #2 {main} thrown in /homepages/44/d157697781/htdocs/GoogleVoice.php on line 66

Script stopped working: Could not parse for GALX or gxf token

The script was working earlier but stopped.. It throws this error now.

An uncaught Exception was encountered
Type: Exception

Message: Could not parse for GALX or gxf token. Inputs from page: array ( )

Filename: /usr/share/nginx/html/application/libraries/Gv_lib.php

Line Number: 55

Backtrace:

File: /usr/share/nginx/html/application/libraries/Gv_lib.php
Line: 159
Function: _logIn

File: /usr/share/nginx/html/application/controllers/Notification.php
Line: 42
Function: sendSMS

File: /usr/share/nginx/html/index.php
Line: 292
Function: require_once

..It might have something to do with this:

curl https://accounts.google.com/signin/challenge/sl/password
<HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A HREF="https://accounts.google.com/ServiceLogin">here</A>.
</BODY>
</HTML>

I've tried setting the post sign-in $URL to be: https://accounts.google.com/signin/v1/lookup to no avail.

Both getUnreadSMS() getReadSMS() appear to only return the first text of a "thread"

If I send by sms "Text 1," "Text 2," and "Text 3," to my Google Voice account, the texts retrieved by Google-Voice-PHP-API would only include "Text #1" for texts recieved from a single number in a short period of time.

I'm afraid I don't know enough about Google Voice to know if this is a limitation of what Google exposes or not, but I hope you could offer a solution in either case. Cheers.

Looking for new maintainer

I am looking for a new maintainer of this library. I would be happy to transfer the repo to someone with a history of maintaining PHP libraries on GitHub. Please comment with a link to one or two libraries that demonstrate your ability to maintain a repository over time.

Subject

I know this may be a random request/question, but is there a way to include a subject in an outgoing sms?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.