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

It's probably a longshot Getting Obi to support this but I have a partial work around that functions now and will continue to function after the XMPP cut off.  This trick requires the Obi device to call a url.  It would not require users to share their passwords either.  This ability to "call" a predefined url could also be used with other peoples Hacks to generate a callback as well.

I'm not talking about dialing an ip address with sip.  Instead the Obi opens a url similar to the way a browser would.  It would work in a fashion similar to my dynamic DNS hack.  In my testing it all works so far but I need to fine tune the code.  I would also need OBi to allow us to opem a url by dialing a number.  I envision a speed dial.


The very basics of how this works.

Set up a Google Call widget.  Under the options set the widget so the call goes directly to voicemail.  Plug the secret key into a small form that will post automatically when it's called.  

When the form is called you will receive a call that connects you to your own voicemail.
Now you can listen to your voicemail and dial outgoing calls for free.

I would also like to find a way to host the form on the actual Obi.  I think I might be able to do that with the OBi202.  I am testing code hosted on a USB drive on my Obi202 right now.

Using this trick you could also set up speed dials for other Google Voice users that would connect without going through your voicemail to place the call.

This would also help support services that provide callback.  It's a little complicated now but I'm simplifying it as we speak.  


Long live our new ObiLords!

giqcass

I have made the fist OBi initiated call.  I have not yet been able to host the code on the Obi and make it work but when I host a PHP version of the code on a free webserver it works.

After I uploaded the code to the webserver I was able to paste that code into my obi just like I did for the Dynamic DNS hack.  I set the interval to 120 seconds for the sake of testing and the Obi initiated a Google Voice callback to my phone on schedule.  This connected me to my voicemail and I was able to place an outgoing call as expected.

If Obi would add the ability to post to a url by dialing a code this will workå
Long live our new ObiLords!

sdb-

Clever!

I have not looked at using the google widget.
Is your PHP code downloadable or short enough to post?  (after obscuring your info)

giqcass

It's not really my code.  I just re-purposed the code someone else wrote for a tutorial.   Only 2 variables must be set. I'm playing with an alternate technique as well.  It's going to be more difficult but it will work better when finished.  It will also use an http request but it allows you to dial any number without going through voicemail first.

Primary code came from here.
http://www.html-form-guide.com/php-form/php-form-submit.html

This article helped me with the variables.
http://razvangavril.com/web-development/custom-google-voice-widget/

I still don't have a version that will work when hosted on the Obi via usb drive.  The Obi can activate the code when hosted on a free web host by using a http request.  I have tested this code hosted on 000webhost.com.

<?php
 
//Replace the following two Variables.
$GoogleVoiceKey 'a3d34f94jf94jfj98f1da53jfiejgkej12710aa2'//This comes from the GV widget
$CallBackNumber =  '15555551212'//This is the number Google should call.

//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//Leave this stuff alone don't make any changes below 
//unless you know what you are doing.
//This script will allow you to place a call
//from Google voice to another number.
//it uses the secret key from the Google call widget.
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////




//create array of data to be posted
$post_data['buttonId'] = $GoogleVoiceKey;
$post_data['callerNumber'] = $CallBackNumber;
$post_data['name'] = 'Me';
$post_data['showCallerNumber'] = '1';



 
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
    
$post_items[] = $key '=' $value;
}
 
//create the final string to be posted using implode()
$post_string implode ('&'$post_items);
 
//create cURL connection
$curl_connection =
  
curl_init('https://clients4.google.com/voice/embed/webButtonConnect');
 
//set options
curl_setopt($curl_connectionCURLOPT_FRESH_CONNECT1);
curl_setopt($curl_connectionCURLOPT_CONNECTTIMEOUT30);
curl_setopt($curl_connectionCURLOPT_USERAGENT,
  
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connectionCURLOPT_RETURNTRANSFERtrue);
curl_setopt($curl_connectionCURLOPT_SSL_VERIFYPEERfalse);
//curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, true);
 
//set data to be posted
curl_setopt($curl_connectionCURLOPT_POSTFIELDS$post_string);
 
//perform our request
$result curl_exec($curl_connection);
 
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo 
curl_errno($curl_connection) . '-' .
                
curl_error($curl_connection);
 
//close the connection
curl_close($curl_connection);
 
?>


Long live our new ObiLords!

giqcass

I'm done playing with solution number 1.  If anyone would like to test is then go ahead and try this live test version.  You need to supply your own secret key from a Google Voice widget.
I can think of a few creative ways to use this but the more complex version will be more versatile.

Replace "YOUR-SECRET-KEY" with the one from the widget and the number with your telephone number or the number of someone you want to call.  I would give them a heads up first before you call them.  It will call them and ask them to press 1 to connect with you.  Caller ID will show
QuoteMountain Vie CA  16502651193
http://gvtest.site88.net/?key=YOUR-SECRET-KEY&callback=15554441212&name=optional

This article will help you find the key.  The key looks something like this. 4563a8e24f4009bcaf7122437e2f9bc0b15c192e

New code below.
<?php

echo 'This is a GV callback test page.<BR>';
echo 
'You must provide your secret key and callback number.<BR>';
echo 
'Add it to the url like this.<BR>';
echo 
'?key=YOUR-RANDOM-SECRET-KEY-FROM-WIDGET&callback=15552221212&name=OPTIONAL<BR><BR><BR>';
//
//////////////////////////////////////////////////////////
//There are 2 way to pass the variables. 
//
//Option 1 - In the URL
// http://www.yourdomain.com/ObigvTest.php?key=YOUR-RANDOM-SECRET-KEY-FROM-WIDGET&callback=15552221212&name=OPTIONAL
//
//Option 2 - Replace the following two Variables.
$GoogleVoiceKey 'YOUR RANDOM SECRET KEY FROM WIDGET';
$CallBackNumber =  '15552221212'//This is the number Google should call.

//This variable is optional
$Name 'Google Voice';

//////////////////////////////////////////////////////////
//Leave this stuff alone don't make any changes below 
//unless you know what you are doing.
//Any variable included in the url will replace variables 
//defined in option 2.
//This script will allow you to place a call
//from Google voice to another number.
//it uses the secret key from the Google call widget.
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////

///If variables are in the url then override pre defined variables
 
$Key htmlspecialchars($_GET["key"]) ;
 
$CallBack htmlspecialchars($_GET["callback"]) ;
 
$Name htmlspecialchars($_GET["name"]) ;

if (
$Key != null)
  
$GoogleVoiceKey $Key;

if (
$CallBack != null)
  
$CallBackNumber $CallBack;

if (
$Name != null)
  
$GvName $Name;

echo 
$GoogleVoiceKey ' ' $CallBackNumber ' ' $Key ' ' $CallBack  ;


//create array of data to be posted
$post_data['buttonId'] = $GoogleVoiceKey;
$post_data['callerNumber'] = $CallBackNumber;
$post_data['name'] = '$GvName';
$post_data['showCallerNumber'] = '1';



 
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
    
$post_items[] = $key '=' $value;
}
 
//create the final string to be posted using implode()
$post_string implode ('&'$post_items);
 
//create cURL connection

if ($Key != null) {
  
$GoogleVoiceKey $Key;

  
$curl_connection =
    
curl_init('https://clients4.google.com/voice/embed/webButtonConnect');
 
}
//set options
curl_setopt($curl_connectionCURLOPT_FRESH_CONNECT1);
curl_setopt($curl_connectionCURLOPT_CONNECTTIMEOUT30);
curl_setopt($curl_connectionCURLOPT_USERAGENT,
  
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connectionCURLOPT_RETURNTRANSFERtrue);
curl_setopt($curl_connectionCURLOPT_SSL_VERIFYPEERfalse);
//curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, true);
 
//set data to be posted
curl_setopt($curl_connectionCURLOPT_POSTFIELDS$post_string);
 
//perform our request
$result curl_exec($curl_connection);
 
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo 
curl_errno($curl_connection) . '-' .
                
curl_error($curl_connection);
 
//close the connection
curl_close($curl_connection);
 
?>
Long live our new ObiLords!

giqcass

I'm working on the callback script based on work found here.  It's a better solution then the one above.  If I can get Obi to give us the ability to post a url Based on a speed dial then it should work as follows. 

1) Dial the speed dial.
2) Hang up.
3) You immediately receive an incoming call.
4) Pick up the phone and the call will ring the number defined in the speed dial.

Not as seamless as the current system but it's free and it will work after the 2014 cutoff date.
Long live our new ObiLords!

azrobert

Quote from: giqcass on November 28, 2013, 02:19:21 AM
I'm working on the callback script based on work found here.  It's a better solution then the one above.  If I can get Obi to give us the ability to post a url Based on a speed dial then it should work as follows. 

1) Dial the speed dial.
2) Hang up.
3) You immediately receive an incoming call.
4) Pick up the phone and the call will ring the number defined in the speed dial.

Not as seamless as the current system but it's free and it will work after the 2014 cutoff date.

I was testing this script with Tropo. I deleted my last post because Tropo doesn't support cookies and the script will not work. Since then I tried running the script without cookies. I actually got it to log into GV successfully, but instead of returning a key Google sent a message stating cookies must be enabled.

Are you testing this script? Are you having better results than me?

Can you recommend any free service that can host this script?

Thanks

giqcass

Quote from: azrobert on December 18, 2013, 01:19:30 PM
Quote from: giqcass on November 28, 2013, 02:19:21 AM
I'm working on the callback script based on work found here.  It's a better solution then the one above.  If I can get Obi to give us the ability to post a url Based on a speed dial then it should work as follows. 

1) Dial the speed dial.
2) Hang up.
3) You immediately receive an incoming call.
4) Pick up the phone and the call will ring the number defined in the speed dial.

Not as seamless as the current system but it's free and it will work after the 2014 cutoff date.

I was testing this script with Tropo. I deleted my last post because Tropo doesn't support cookies and the script will not work. Since then I tried running the script without cookies. I actually got it to log into GV successfully, but instead of returning a key Google sent a message stating cookies must be enabled.

Are you testing this script? Are you having better results than me?

Can you recommend any free service that can host this script?

Thanks


I'm having issues with it as well.  I always end up with errors.  It needs a rewrite to work with the free hosts.  I haven't dug in to it enough yet. 
Long live our new ObiLords!

giqcass

I will have to figure out the code but I believe I have finally figured out a system to initiate a free outbound call.  It's a callback solution. Dial in to a sip number.  Leave a voicemail.  The voicemail is forwarded to a cloud service that initiates the GV callback or any number of other tasks.  This would of course be much simpler if obi would implement a way to send a url call with variable.  I will try to get some simple tasks going over the next week.  I see no reason why we couldn't dictate a text message using this system.
Long live our new ObiLords!

giqcass

I haven't posted any update to this thread in a while but I have finally worked out a method to pass a variable to a url.  It is described in the Obi provisioning documentation but until recently I wasn't able to put the pieces together.
Currently I am refining the process.
Long live our new ObiLords!

giqcass

Use Speed Dial 99 to store a variable representing the Phone number you want to call.  Pass that variable to a url that will initiate the call. 


System Management
>>>>>>>>>>>>>>>Auto Provisioning
>>>>>>>>>>>>>>>>>>>>>>>>>>>Auto Firmware Update
Method = Periodically
Interval = 5
FirmwareURL  =  IF ( $UDM0 >=1 ) FWU http://www.yourdomain.com/secretkey/$UDM0



System Management
>>>>>>>>>>>>>>>Auto Provisioning
>>>>>>>>>>>>>>>>>>>>>>>>>>User Defined Macro 0

Value = $SpeedDial.99
ExpandIn = X_DeviceManagement.FirmwareUpdate.FirmwareURL



Notes:   This works but I currently must reset speed dial 99 manually.  I have to work on the syntax to reset Speed dial 99 to 0 or empty after the url call.
Long live our new ObiLords!

giqcass

Thanks to azrobert for this part of the setup.  I was having issues with this string.  This allows you to dial *0 and the number you want to dial to initiate the callback.  The Number you want to dial will be place in slot 99 of your speed dial.

Star Codes
>>>>>>>>>Star code profile A
>>>>>>>>>>>>>>>>>>>>>>Code 30  = *0(<99>), Set Speed Dial, coll($Spd[$Code])


Quote from: azrobert on March 15, 2014, 08:54:14 AM
Set StarCode#30 to:
*0(<99>), Set Speed Dial, coll($Spd[$Code])

Dial *018005551212

I will have to work on the logic that resets the variables after the call now.  Currently this must be done manually.
Long live our new ObiLords!

giqcass

This is the state of my current best process for free Google Voice callback initiated via telephone. It requires a lot of setup and is not ready for everyone.  I have had a lot of help from azrobert. This involves using code found here.  You must install it on your own web server.  I have not found a free host that is compatible yet however it can be run on a home web server and on some paid web servers.  The primary requirements are that the server does not have an open base directory and PHP is not running in safe mode.  I have hopes of modifying the script to work on a free web host.  Speed dial 99 must be left blank to use this trick.  That is where the number is stored for callback.  

Once everything is set up you can dial the number you want to call.  Using the *0 and then the number.
You will hear a confirmation tone then hang up.  
You will receive an incoming call and when you pick up the phone the number you dialed will be connected.

One limitation is that you can not dial the exact same number twice in a row.  If you wish to place a call to the last person you dialed you may redial the number with a different format then the one you used last time. If you dialed *014195551212 last time then this time you must dial *04195551212 to place the call.


http://192.168.1.100:5090 must be replaced with the address of the web server you uploaded  this code to.

Modifications to the Obi.
Star Codes
>>>>>>>>>Star code profile A
>>>>>>>>>>>>>>>>>>>>>>Set star code 30 as follows
*0(1xxxxxxxxxx|[2-9]xxxxxxxxx), Set Speed Dial, set($Spd[99],$code)


System Management
>>>>>>>>>>>>>>>Auto Provisioning
>>>>>>>>>>>>>>>>>>>>>>>>>>>Set ITSP Provisioning as follows.
Method = Periodically
Interval = 5
ConfigURL  = SET TPRM1 = $UDM0; @loop IF ( $TPRM1 != $UDM0 ) SYNC http://192.168.1.100:5090/gvcall.PHP?cancel=no&dialnum=$UDM0; SET TPRM1 = $UDM0; WAIT 5; GOTO loop;



System Management
>>>>>>>>>>>>>>>Auto Provisioning
>>>>>>>>>>>>>>>>>>>>>>>>>>Set User Defined Macro 0 as follows.

Value = $SpeedDial.99
ExpandIn = ALL



Thanks to azrobert for his latest help and thank you to Aaron Parecki for the Google Voice API.  Hopefully setup can eventually be simplified and the last few bugs ironed out.
Quote from: azrobert on March 21, 2014, 09:50:20 PM
The following works.

ITSP Provisioning:
Method: System Start
ConfigURL:
SET TPRM1 = $UDM0; @loop IF ( $TPRM1 != $UDM0 ) SYNC http://192.168.1.100:5090/gvcall.PHP?cancel=no&dialnum=$UDM0; SET TPRM1 = $UDM0; WAIT 5; GOTO loop;

Dial *01623594100
You don't have to reset Speed Dial 99.

The dialed number must be different than the last number dialed.
If you want to redial, dial the number with/without country code so it will be different than the last number dialed.

Long live our new ObiLords!

giqcass

azrobert has made some upgrades that I plan to test myself.  I am currently running the same php code found here. I am running it on my Mac without adding any additional software.  Mac has apache built in so you just need to turn on the webserver and php.

Quote from: azrobert on March 22, 2014, 08:59:58 AM
I made some changes.
I didn't like *0, so I changed it to just *
I added 7 digit dialing. Change 480 in the StarCode30 to your local area code.
I added a redial feature (*00). It can only be used once after dialing a number.

StarCode30:
*(1xxxxxxxxxx|xxxxxxxxxx|<1480>xxxxxxx|00), Set Speed Dial, set($Spd[99],$code)

ITSP Provisioning:
Method: System Start
ConfigURL:
SET TPRM1 = $UDM0; @loop IF ( $UDM0 == 00 ) GOTO redial; SET TPRM2 = $UDM0; GOTO checkit; @redial SET TPRM2 = $TPRM1; @checkit IF ( $TPRM1 != $UDM0 ) SYNC http://192.168.1.100:5090/gvcall.PHP?cancel=no&dialnum=$TPRM2; SET TPRM1 = $UDM0; WAIT 5; GOTO loop;

I refined this method, but this was giqcass' idea. I would have never thought of this hack.
This is a better method than the one I was using with the Wamp Server.
Anyway, thank you giqcass.
Long live our new ObiLords!

azrobert

giqcass,

In another thread you said you looked at Tropo.

Tropo is what I originally used to get the callback script to work. The callback script won't run under Tropo, but you can use it to bridge SIP to HTTP. I have 2 versions.

Version 1
Tropo initiates the callback via the Wamp Server.
The Tropo script waits 40 seconds.
You don't have to hang up.
When the callback arrives, you hear the Call Waiting tone.
Hit flash to connect to the call.
You can also hang up and wait for the callback to ring your phone.


Version 2
Tropo initiates the callback via the Wamp Server.
The Tropo script enters a Tropo conference.
You don't hang up.
The callback number is pointed to the same conference.
When the callback arrives you are connected without doing anything.
When you hang up the Tropo script issues a GV call cancel via Wamp.
If you didn't cancel the call and the callee didn't hang up, they would stay connected to the conference.


IMHO, the best way to run the callback script is under Asterisk. With Asterisk you can also merge the outgoing call with the callback.

giqcass

Asterisk would be the most seamless option without an outside server or service.  I signed up for a Tropo account and spent some time poking around.  I have been more a Voxeo user.  I didn't use either for a callback script.  I mostly use Voxeo to route incoming Skype calls.  I have a Skype user name that forwards to the free +990 number that Voxeo(and tropo) provide. Should anyone try this only the older versions of Skype let you enter the +990 number as a forwarding number.  Skype doesn't charge to call or forward to +990 numbers.

I have yet to install my own Asterisk server but I'm considering a Raspberry Pi or Beagle bone black.  Once you have an Obi then Asterisk seems to be the logical next step if you want to upgrade.
Long live our new ObiLords!

azrobert

You can run PBX in a Flash in a virtual machine. I know you have a Mac and there are versions that will run on your machine.
See: http://pbxinaflash.com/vm/

I'm running PIAF under VMWARE on an XP machine. On a virtual machine you can install a newer version of PIAF without deleting the old version. On a Raspberry Pi  you can do the same by buying another sdhc card.

This is my hardware. It' about the size of a large paperback book and the only moving part is the hard drive.
http://www.cnet.com/products/shuttle-xs35-702-atom-d510-1-66-ghz/specs/

giqcass

That looks like a nice little unit.  The atom processor probably doesn't require a lot of juice either.
Long live our new ObiLords!

corporate_gadfly

Quote from: azrobert on March 27, 2014, 08:23:37 AM
IMHO, the best way to run the callback script is under Asterisk. With Asterisk you can also merge the outgoing call with the callback.
I was able to use asterisk (using pygooglevoice for the callback script) and call bridging successfully. Feel like I am somewhat ready for May 15, 2014. The end user experience was a slightly longer ringing tone while the call bridging happens.

Roger

I am trying this out.  I wasn't sure how to pass in my google credentials, so for now I just hard coded them into the php code.  When I try it I heard the numbers dialing, then it sounds like it hangs up and I hear a dial tone again.  When I check the speed dial the number I dialed was added to slot 99, so that part is working.  Is there any way to verify that the php code was loaded into the Obi?