skip to Main Content

I am a very beginner so forgive me if its too basic .

I have set a localhost using MAMP and i have a index.php file that call me via Twilio, and its working great i get calls always:

<?php

$id = "ACxx15d26xxxxxxxxx454424bxxexx3f";
$token = "79fb4xxxf93c8exxxxxxxda6bxxxxe9 ";  
$url = "https://api.twilio.com/2010-04-01/Accounts/$id/Calls.json";
$CallURL = "http://www.someweb.com";
$from = "+97223721333";
$to = "+971111111111"; // twilio trial verified number
$body = "Its all going to work!";
$data = array (
    'From' => $from,
    'To' => $to,
    'Body' => $body,
    'Url' => $CallURL,  

);
$post = http_build_query($data);
$x = curl_init($url );
curl_setopt($x, CURLOPT_GET, true);
curl_setopt($x, CURLOPT_RETURNTRANSFER, true);
curl_setopt($x, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($x, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($x, CURLOPT_USERPWD, "$id:$token");
curl_setopt($x, CURLOPT_POSTFIELDS, $post);
$y = curl_exec($x);
curl_close($x);
var_dump($post);
var_dump($y);
 ?>

Then i have set an Amazon server EC2 , and i have put a few files in there (filezilla) which worked also(i can load images in the browser-and it works).

Then i have tried to put this file in the server, well there are 2 things happened.

  1. when i put it as index.php , and browse there , i could see a blank page and nothing happened .
  2. when i put it as index.html and browse there , i have got this text (“which is not Json,so i dont know what it is) , and i didn’t get the call also :

    $from, ‘To’ => $to, ‘Body’ => $body, ); $post =
    http_build_query($data); $x = curl_init($url ); curl_setopt($x,
    CURLOPT_POST, true); curl_setopt($x, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($x, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($x,
    CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($x, CURLOPT_USERPWD,
    “$id:$token”); curl_setopt($x, CURLOPT_POSTFIELDS, $post); $y =
    curl_exec($x); curl_close($x); var_dump($post); var_dump($y); */
    //twillio call $id = “ACa015xx662d50dxxx454424b70xxxxxx”; $token =
    “79fb4b00efxxc8exxxf772da6bxxxxxx “; //only after : in the website
    $url = “https://api.twilio.com/2010-04-01/Accounts/$id/Calls.json”;
    $CallURL = “http://www.somewebsite.com“; $from = “+97223721333”; $to =
    “+ 971111111111”; // twilio trial verified number $body = “Its all
    going to work!”; $data = array ( ‘From’ => $from, ‘To’ => $to, ‘Body’
    => $body, ‘Url’ => $CallURL, ); $post = http_build_query($data); $x = curl_init($url ); curl_setopt($x, CURLOPT_GET, true); curl_setopt($x,
    CURLOPT_RETURNTRANSFER, true); curl_setopt($x, CURLOPT_SSL_VERIFYPEER,
    false); curl_setopt($x, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($x, CURLOPT_USERPWD, “$id:$token”); curl_setopt($x,
    CURLOPT_POSTFIELDS, $post); $y = curl_exec($x); curl_close($x);
    var_dump($post); var_dump($y); ?>

So , whats the different between putting it as .php and .html ? why is one of them is blank and the other has this respond ?

EDIT

I have tried to install curl with : sudo apt-get install php5-curl(worked)

then i have tested to see if i have curl supported with this link:
How to enable cURL extension on Amazon EC2 free tier
result is that its not supported.
Why is that ? i have installed it.

2

Answers


  1. Chosen as BEST ANSWER

    first i had to add the curl sudo apt-get install php5-curl

    But then, to restart the apache !!!

    sudo service apache2 restart
    

    No restart- not working !


  2. Changing the file extension changes how the server handles serving the file when someone requests the file. E.g. if someone requests an image, it sends image headers to the receiver so it (usually the browser) knows to display it as an image. If someone requests a video, the server will send the appropriate headers to inform the receiver that a video is on its way.

    In your case, changing from PHP to HTML will change how the server handles it, from parsing it as a PHP file to not parsing it as a PHP file when you change it to a .HTML file. This could signify that you have an error in your PHP code, or that your server isn’t handling PHP files properly. The output you see when it’s a HTML file is your php code being parsed as plaintext. This is bad and insecure as it could output your passwords to the user.

    To check if your PHP code has errors, view the error log in the error log directory that’s stated in your php.ini. Also, whilst you’re developing, it may be worth setting display_errors to on so you don’t see a blank screen when you get a coding error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search