2

Controller

public function searchNew()
{


    $sid = //account_sid; 
    $token = //auth_token; 
    $client = new Services_Twilio($sid, $token);

    $country = $this->input->post('select_country');
    $type = $this->input->post('type');
    $params = array(
        'Contains' => $this->input->post('contains'),
        'SmsEnabled' => $this->input->post('SMS'),
        'MmsEnabled' => $this->input->post('MMS'),
        'VoiceEnabled' => $this->input->post('Voice'),
        'ExcludeAllAddressRequired' => TRUE,
        'ExcludeLocalAddressRequired' => TRUE,
        'ExcludeForeignAddressRequired' => TRUE
    );

    $numbers = $client->account->available_phone_numbers->getList($country, $type, $params);

    return $numbers;
}

View

<form action="<?php echo base_url('tenant/phone_numer/searhNew');?>" method="post">
<input type="text" name="contains" class="form-control mbottom1" id="user_firstname" placeholder="Enter a description name for your number">

<select name="select_country" id="select_country" class="form-control">
<option disabled selected>Country</option>
<option value="US">USA (+1)</option>
</select>

<input id="checkcap1" type="checkbox" name="Voice" class="radio1" value="True"/>Voice

<input id="checkcap2" type="checkbox"  name="SMS" class="radio1" value="True"/>SMS

<input id="checkcap3" type="checkbox" name="MMS" class="radio1" value="True"/>MMS

<input id="checktype1" type="radio" name="type" class="radio2" value="Local"/>Local

<input id="checktype2" type="radio" name="type" class="radio2" value="Mobile"/>Mobile

<input id="checktype3" type="radio" name="type" class="radio2" value="TollFree"/>Toll-Free

<input id="checktype3" type="radio" name="type" class="radio2" value="National"/>National

<button type="Submit">Test Submit</button>
</form>

I need help in getting the $country,$type,$params from my view file. I have done a few testing and when I change $country = $this->input->post('select_country'); to $country = "US" and the other variables into a static value, the code works fine, but when I change it their respective inputs the error message I am receiving is

The requested resource /2010-04-01/Accounts/acount_sid/AvailablePhoneNumbers//Tollfree.json was not found

Thanks for any help.

Nikhil Vaghela
  • 2,088
  • 2
  • 15
  • 30
Beldion
  • 321
  • 8
  • 19
  • are you having this problem only when you change to this **$country = $this->input->post('select_country');** from this **$country = "US"** ? – Mittul Chauhan Aug 11 '16 at 04:45
  • first make sure whether it is happening with particular this country field or not by putting other parameters dynamic using POST field .. – Mittul Chauhan Aug 11 '16 at 04:46
  • also use $_POST to make sure you are getting all the values or not with their respective keys you are using in your php code .. and make sure there is not any space .. trim it if its there. – Mittul Chauhan Aug 11 '16 at 04:48
  • It looks to me, from the path in the error, that you are not passing a country properly. I'd do what Mit.agile is suggesting and just replace the incoming post with a string to test. Then you can work out where the issue is really coming from. – philnash Aug 11 '16 at 10:22

1 Answers1

0

Do it with step by step flow of codeigniter.. After submit form , In controller print your post data..

print_r($_POST);

Check all data come from Form.. And check all by isset and pass in params,type , category. It will working fine..One More thing , In twilio library all parameters passing are important e.g.

$params=array(); 
if(isset($this->input->post('Voice'))){
   $params['VoiceEnabled']=$this->input->post('Voice');  
}
Kumar Rakesh
  • 2,718
  • 2
  • 18
  • 39
  • 1
    still receiving the same error, i think the issue is with the way I am passing the data to twilio... – Beldion Aug 11 '16 at 08:46
  • You should be passed all parameters. I have also use twilio library for voice call. Its working fine for me. Check all post parameters.. Thanks – Kumar Rakesh Aug 11 '16 at 08:56