Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Link Button not working, after putting in phone number
    primarykey
    data
    text
    <p>I am working on implementing a get link button that will send you a link via text once you type your phone number in the textfield. I am using Twilio to handle my SMS stuff, and I am following an app tutorial that teaches exactly what I am trying to implement. This is the tutorial and the ideal implementation of what I'd like to do, respectively:</p> <p><a href="http://www.apptamin.com/blog/app-download-button/" rel="nofollow">http://www.apptamin.com/blog/app-download-button/</a></p> <p><a href="http://getmaid.com/" rel="nofollow">http://getmaid.com/</a></p> <p>So far I have made an easy html file that just displays the button, a message, and the text field. This is the code for that file:</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Text Me The Link!&lt;/title&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //Javascript $(function(){ $("#frm").submit(function(e){ e.preventDefault(); $.post("textMeLink.php", $("#frm").serialize(), function(data){ if(data.sms_sent == 'OK'){ alert("Message Sent"); } else { alert("Message Not Sent"); } }, "json"); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="frm" name="frm"&gt; &lt;input type="hidden" name="ajax" value="1"/&gt; &lt;h4&gt;Text your phone a download link for our iPhone and Android apps&lt;/h4&gt; &lt;input type="phone" name="phone" placeholder="Enter Your Mobile Number"/&gt; &lt;button type="submit"&gt;Get Link&lt;/button&gt; &lt;div style="display: none; " class="error"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>the PHP file works like a charm. I've tested it independently and I get SMS messages from Twilio without any issue. The problem is when I try it from the html file. Whenever I enter a phone number I get no alert, and the only thing that changes is the link it goes </p> <p>from:</p> <pre><code>file:///C:/Users/Kevin/Marco%20Polo/twilio-php-master/sendLinkV0.html </code></pre> <p>to:</p> <pre><code>file:///C:/Users/Kevin/Marco%20Polo/twilio-php-master/sendLinkV0.html?ajax=1&amp;phone=1234567890 </code></pre> <p>After that no matter what other numbers I try, nothing works, the only thing that changes is the number at the end of the link and no SMS are ever sent by Twilio. I might just be missing a small part or probably am unaware that I have to have the file in the server instead of my C: drive, maybe I don't know. So if anyone is able to see where I went wrong, and explain why it's failing, that would be awesome!</p> <p>Thanks,</p> <p>Everyone</p> <p>P.S. the html, php files as well as the Twilio library are all in the same directory which was changed in the WAMP httpd.conf file to be the new Documentroot</p> <p><strong>EDIT</strong></p> <p>I ran my php code and it seems that there error was with the code on the php file and it may not have been an issue with the html file. Here is my php file:</p> <pre><code>&lt;?php require "Services\Twilio.php"; $AccountSid = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $AuthToken = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; $client = new Services_Twilio($AccountSid, $AuthToken); $phone=$_POST["phone"]; $sms = $client-&gt;account-&gt;sms_messages-&gt;create( "+17327047999", $phone, "Get our app now: http://play.google.com/store/apps/details?id=some.app" ); $sms_check="OK"; $return_json = '{"sms_sent":"' .$sms_check . '"}'; echo $return_json; ?&gt; </code></pre> <p>It seems like the error stems from the fact way I've defined my $phone variable. The errors I get read:</p> <pre><code> Notice: Undefined index: phone in C:\Users\Kevin\Marco Polo\twilio-php-master\textMeLink.php on line 9 Warning: file_get_contents: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\Users\Kevin\Marco Polo\twilio-php-master\Services\Twilio\HttpStream.php on line 61 Fatal error: Uncaught exception 'Services_Twilio_HttpStreamException' with message 'Unable to connect to service' in C:\Users\Kevin\Marco Polo\twilio-php-master\Services\Twilio\HttpStream.php on line 64 Services_Twilio_HttpStreamException: Unable to connect to service in C:\Users\Kevin\Marco Polo\twilio-php-master\Services\Twilio\HttpStream.php on line 64 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload