0

I am trying to paginate the records for Twilio and after taking the reference from here

I have added the next page and previous page url and its showing successfully but when I am opening the url, its showing the error i.e.

"code": 20003,
"detail": "Your AccountSid or AuthToken was incorrect.",
"message": "Authentication Error - No credentials provided",
"more_info": "https://www.twilio.com/docs/errors/20003",
"status": 401

Here is my code :

public function listcallsapp(Request $request){
  $calls = $this->twilio->calls->page([], 50);

  $data = [];
  $i = 0;
  foreach($calls as $call){
      $data[$i]['sid'] = $call->sid;
      $data[$i]['from'] = $call->from;
      $data[$i]['to'] = $call->to;
      $data[$i]['direction'] = $call->direction;
      $data[$i]['status'] = $call->status;
      $data[$i]['duration'] = $call->duration;
      $i++;
  }
  
  return response()->json([
      'message'=>'Call Logs!',
      'code'=>200,
      'prev' => $calls->getPreviousPageUrl(), 
      'next' => $calls->getNextPageUrl(),
      'data'=>$data,
      'status'=>'success'
  ]);
}

Where I am missing, please help me out. Also, If any other way, please suggest.

  • `when I am opening the url` - you didn't show us the code that does that. Use `getPage()` to get the URL you get from `$calls->getPreviousPageUrl()` etc. [Maybe this answer helps](https://stackoverflow.com/questions/41542942/twilio-how-to-do-pagination-with-messages/65200354#65200354). – Don't Panic Dec 13 '20 at 13:52
  • I am working on postman, so there is no any view, – Bhawesh Bhakar Dec 14 '20 at 05:14

0 Answers0