News:

On Tuesday September 6th the forum will be down for maintenance from 9:30 PM to 11:59 PM PDT

Main Menu

Speed dial to post to url. Part of my Google voice 2014 workaround.

Started by giqcass, November 07, 2013, 01:12:22 AM

Previous topic - Next topic

giqcass

Quote from: Roger on April 10, 2014, 09:14:46 AM
I am trying to implement this with Aaron's googlevoice.php code, but I don't see where to add my google voice credentials.
googlevoice.php remains completely untouched when you implement it.

Please have a look at example.php.  That's where all of the code you need to modify is.  Most of the code isn't needed.  Let us know if you need additional help.
Long live our new ObiLords!

Roger

I have tested out the code and am able to place a call using the sample php code below, but not from the Obi.  What I don't understand is how the Obi sends my username and password to the php code and how the Obi knows to call the callNumber function within the php code. 

<?php

ini_set('display_errors', 'On');

include('gvcall.php');

// NOTE: Full email address required.
$gv = new GoogleVoice('username@gmail.com', 'passwd');

// Call a phone from one of your forwarding phones.
$gv->callNumber('12123334444', '16315971111', 'home');

?>

For anyone else trying this out, adding "ini_set('display_errors', 'On');" to the code will provide useful error messages.  I had to install php5-curl which didn't come with my basic php install.

azrobert

FYI I deleted all the code in the script except Login, callnumber and cancelcall.
This is not necessary.

I added some code to the Example script.
I hard coded all the parms in the script except the outbound number.
From the OBi I sent the script the outbound number and another parm.
Based on the value of the extra parm I did a callnumber or a cancelcall.

Edit:
If you are running the script on a Web server you don't need the cancelcall. Always do a callnumber.


azrobert

I re-read your post and I'm not sure I answered your question.
Are you asking how to pass parms to the script?

Call the script like this:
http://192.168.1.100:5060/gvcall.PHP?dialnum=18005551212

In the script do:
$dialnum = $_GET["dialnum"];
$gv->callNumber($dialnum, '3601234567', 'home');

Roger

Thanks so much azrobert and giqcass for your help.  I didn't know I needed to add to the script.  I am now able to place a call via a URL as such:

http://localhost/gv.php?dialnum=12123334444

Please bear with me as I am learning PHP as I go, but I have a two more questions:

1) Do I use the configURL to get the Obi to execute the URL: http://localhost/gv.php?dialnum=12123334444?
Here is my configURL: 

SET TPRM1 = $UDM0; @loop IF ( $TPRM1 != $UDM0 ) SYNC http://192.168.1.145/gv.php?dialnum=$UDM0; SET TPRM1 = $UDM0; WAIT 5; GOTO loop;

Does that look okay?  192.168.1.145 is the server IP from my router, which sits behind my Obi.  Will the Obi be able to get to that address?

2) While I am able to place a call via a URL from my localhost, when I put the same php code on a website hosted by fatcow.com I get an error when placing a call.  Would you be able to guess the problem based on the error message below?

Fatal error: Uncaught exception 'Exception' with message 'Could not log in to Google Voice with username: username@gmail.com' in /hermes/waloraweb099/b1942/moo.xxxxx/gvcall.php:67 Stack trace: #0 /hermes/waloraweb099/b1942/moo.xxxxx/gvcall.php(89): GoogleVoice->_logIn() #1 /hermes/waloraweb099/b1942/moo.xxxxx/gv.php(15): GoogleVoice->callNumber('12123334444', '16314445555', 'home') #2 {main} thrown in /hermes/waloraweb099/b1942/moo.xxxxx/gvcall.php on line 67

azrobert

1)
Try it and see what happens.
Don't forget "Method=System Start" under provisioning and the Star Code.

2)
In the script try changing the code under the Login section to: 
               $this->_ch = curl_init();
                curl_setopt($this->_ch, CURLOPT_COOKIEJAR, $this->_cookieFile);
                curl_setopt($this->_ch, CURLOPT_FOLLOWLOCATION, TRUE);
                curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, TRUE);
                // Withtout the next line I get cURL errors
                curl_setopt($this->_ch, CURLOPT_SSL_VERIFYPEER, false);

                curl_setopt($this->_ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows

I never used a VPS, but you should install PBX in a Flash. I think Asterisk is a better solution. It's a harder install than a Web Server, but not that much. If you go this route, PHP retrieves parms differently under Asterisk.

azrobert

I said:
QuoteI never used a VPS, but you should install PBX in a Flash. I think Asterisk is a better solution. It's a harder install than a Web Server, but not that much.

I think this is bad advice. I assume the VPS will require you to use their OS. PIAF installs CentOS, so you will need to install Asterisk by itself.


Roger

Quote from: azrobert on April 12, 2014, 10:19:44 AM
1)
Try it and see what happens.
Don't forget "Method=System Start" under provisioning and the Star Code.

I did set Method to System Start and added the Star Code.  The number I want to call does show up in speed dial #99, so that part is working.   When I try it after it dials the number (*12124445555) it hangs up and gives me back a dial tone.  I hang up but never get a call back.

2)
In the script try changing the code under the Login section to: 
               $this->_ch = curl_init();
                curl_setopt($this->_ch, CURLOPT_COOKIEJAR, $this->_cookieFile);
                curl_setopt($this->_ch, CURLOPT_FOLLOWLOCATION, TRUE);
                curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, TRUE);
                // Withtout the next line I get cURL errors
                curl_setopt($this->_ch, CURLOPT_SSL_VERIFYPEER, false);

                curl_setopt($this->_ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows

I added the line you suggested, but the problem is that google security is blocking the browser sign-in attempt.  I tried to dismiss it and say it was me, but google still blocks it and I can't figure out how to get it allowed.  I tried 2-step security with an application specific password, but that didn't work either.


azrobert

Sign into Google once with this link:
https://accounts.google.com/ServiceLogin?passive=1209600&continue=https%3A%2F%2Faccounts.google.com%2FDisplayUnlockCaptcha&followup=https%3A%2F%2Faccounts.google.com%2FDisplayUnlockCaptcha

Edit:
When Google detects a new location accessing your account they require you to change your password

or

Use the above link to allow access without PW change.

Roger

I was just going to post that.  DisplayUnlockCaptcha fixed issue #2.  I have updated my configURL to use the external server to eliminate any potential problem with the Obi not seeing the laptop.  When I dial I get a hang up and new dial tone.  I hang up, but don't get a call back.  Does the Obi have a log file or any way to see the error message.  I couldn't find one.

danielbliss

I believe all of this can be done by registering sipsorcery.com and using their GV dial plan.  Does Sip Sorcery no longer offer free accounts (it's been awhile since I used them)?

gderf

Help me OBiHai PhoneOBi. You're my only hope.

danielbliss

Yep, was just checking that out myself.  Bummer.  I was hoping to jump back on my old account there now that the free Obi-GV outbound solution is about to expire. 

giqcass

Quote from: danielbliss on April 17, 2014, 05:49:34 PM
Yep, was just checking that out myself.  Bummer.  I was hoping to jump back on my old account there now that the free Obi-GV outbound solution is about to expire. 
Why can't you use your old free account?  I stopped using mine for at least a year.  Probably longer.  I only had to log in and update my dial plan to get it working again.
Long live our new ObiLords!

danielbliss

Quote from: giqcass on April 19, 2014, 12:18:02 PM
Quote from: danielbliss on April 17, 2014, 05:49:34 PM
Yep, was just checking that out myself.  Bummer.  I was hoping to jump back on my old account there now that the free Obi-GV outbound solution is about to expire. 
Why can't you use your old free account?  I stopped using mine for at least a year.  Probably longer.  I only had to log in and update my dial plan to get it working again.
Before Aaron created paid plans, I donated a chunk of money to him because I enjoyed using his service and benefited from it.  A few months later, he came out with the paid plans and, because I had donated more than he was asking, he offered to freely promote my account to premium for 2 years.  I accepted.  A year later, I bought my Obi, unplugged my Linksys PAP2T and never signed back into SipSorcery: I no longer needed to use the dial plans.

Fast forward to now and the ending of GV's XMPP service.  I tried to log in to SipSorcery and was greeted by a message informing me that I could not log in until I paid some money (because the end of my premium period credit had expired).  I wrote an email to Aaron stating that I only needed a free account now, and asked if he preferred that I simply create a new account or have my existing account downgraded.  That was before I figured out that he was no longer offering free accounts as an option.

I never heard back from him.  I don't blame him.  I'm sure he's not getting rich off of his service: he's probably not even breaking even.  I suppose I could plead the case to him that if I had simply said "never mind, I'll just keep a free account" a few years ago, I'd still have my account... but I know from his forums that he's had to deal with quite a few whiners and I really don't want to add my voice to that chorus.

Bottom line: I don't want to pay $69 a year to keep the account, and will find another solution.  The Obi obviates the need for much of what SipSorcery's dial plans accomplish.  I rarely use my phone and will content myself with a cheap pay-as-you go outbound plan (while continuing to use a free Callcentric DID + GV forwarding for inbound).

UPDATE: Aaron emailed me this morning and reset my account to free.  I may just need to make another donation to SipSorcery.  Can't say enough good things about him and the service his site provides.

Roger

Finally got this to work.  I don't want to admit how long it took me.  For me the problem was the User Defined Macro 0 "ExpandIn" parameter, which I had set to ALL, and wasn't valid on my obi.  The obitalk portal doesn't show the third line, so I didn't notice it, but if you log into the Obi device and look at it there the third line shows "SyntaxCheckResult" and ALL does not PASS.  I changed it to ANY and that shows PASS and now it works.

Thank you SO MUCH to giqcass and azrobert.  This is simply amazing creativity on your parts.

Regarding Sipsorcery, Yes Aaron is a really nice and helpful guy, but the service wasn't working reliably for me, and with the Obi I didn't need to dialplan, which is one of the main features of sipsorcery.

Roger

While I am able to initiate a callback using this method, I am not sure if it is working as it should be.  Trying to understand the configURL it seems that the Obi should only sync when a different number is dialed.  Mine syncs up based on the wait internal.  If I set the weight interval at 5 it syncs up 11 times per minute and if I set the WAIT interval to 15 it syncs up 4 times per minute.  Can anyone clarify this for me?  I have tried to describe how I understand it below.  Maybe that will help highlight any misunderstanding:

Starcode 30 is configured to assign a number to speed dial #99, so when you dial *2125551212 speed dial #99 is populated with 2125551212.  User Defined Macro 0 (UDM0) is set to equal the value of speed dial #99.  Beyond that the main thing to study is the ConfigURL (broken up into lines):

    SET TPRM1 = $UDM0;
    @loop IF ( $UDM0 == 00 ) GOTO redial;
    SET TPRM2 = $UDM0;
    GOTO checkit;
    @redial SET TPRM2 = $TPRM1;
    @checkit IF ( $TPRM1 != $UDM0 ) SYNC http://www.abc.org/gv.php?dialnum=$TPRM2;
    SET TPRM1 = $UDM0;
    WAIT 5;
    GOTO loop;

Temprorary Macro 1 is set to User Defined Macro 0 the first time the Obi starts up.
Then a loop starts. It checks if redial (00) has bee pressed. If so, proceed to @redial.
Otherwise set Temporary Macro 2 to User Defined Macro 0.
So the first time a call is made Temporary Macro 2 will contain the number and Temporary Macro 1 will be blank because it has not been updated yet for the dialed number.
@checkit will find that Temporary Macro 1 will be blank and User Defined Macro 0 will have a number, so the Obi will SYNC and place the call.
The next line after @checkit sets Temporary Macro 1 to equal User Defined Macro 0, so the obi doesn't SYNC again.

azrobert

Roger,

Do you just want to understand the script or is there something wrong?

Here is an explanation of the script:

$UDM0 is the current dialed number.
$TPRM1 is the last dialed number.
$TPRM2 contains the current dialed number or the last dialed number on a redial.

Forget about SYNC. It's just the syntax of the statement.
"SYNC http://www.abc.org/gv.php?dialnum=$TPRM2" executes the URL
"IF ( $TPRM1 != $UDM0 )" != is NOT EQUAL, so I'm checking if a new number has been dialed.
Therefore, the URL is only executed when the current number is not equal to the last number dialed.
You cannot repeat dial the same number, including the redial number.
If you do, the script will not recognize it because the $UDM0 will still be equal to $TPRM1.

The loop is basically doing nothing, except checking if you dialed a new number.
When it detects a new number, it executes the URL.
The wait is how long you want the script to pause before checking for a new number.


Roger

I though there was something wrong because I included an email feature in my php code and I was getting 11 emails every minute, so the URL was getting executed every time through the loop.  By trial and error I seem to have figured out that after you reboot the Obi you have to dial a number and then dial redial to get all the parameters filled in.  After that the URL will only get executed when a call is placed.  So everything seems fine now.  Thanks again.

azrobert

Roger,

What you describe shouldn't happen. The first command gets executed only on startup and sets TPRM1 to equal $UDM0, so the URL shouldn't be executed until you dial a new number. It also shouldn't matter if you set Method to Periodically instead of System Start. You would just execute the script additional times setting TPRM1 to $UDM0.

Even if there was a logic error on startup that I don't see, the script would only be executed once, because the next command sets TPRM1 to $UDM0. Maybe if Speed Dial #99 was set to a null value would cause a problem. I didn't test that condition.

I've been really busy the last few days. I'm trying to get a Raspberry Pi configured and I haven't had much time to spend on that project, so I probably won't look at this for awhile. Let me know if you discover anything.