How not to play for API response page?

Asked

Viewed 34 times

0

By clicking on the button I designed to communicate with the call API, it throws me to a page where it confirms that everything was correct. Do not qeroq play for this page, what I could do, preferably in php?

I didn’t really know how to search to find the answer, I hope I was clear.

<?php
session_start();
$celular = $_SESSION['celular'];
$ddd = $_SESSION['ddd'];
$zero = 0;
$num_com_zero = $zero.$ddd.$celular ; 
$num_s_zero = $ddd.$celular;
header("Location: http://201.76.188.6:8090/call.php?exten=7601&number=$num_com_zero");
?>
  • But you are, literally, redirecting to the API page. That is, the code does only what you don’t want to do, which makes it seem like you don’t understand the code you wrote yourself. What exactly you need to do and why you did it this way?

  • I did so, because I needed to make it work, however, this is not in the perfect way that I would like. One snag is I just have the link to send the number through. what I would really like is to send this number by the link and not go to the API response screen, keep on the msm page q the client was

  • is a "call me" button where the client clicks and the api automatically calls him.

1 answer

3

Fix your code using CURL, make sure that’s what you want.

<?php
    error_reporting(0);
    session_start();
    $celular = $_SESSION['celular'];
    $ddd = $_SESSION['ddd'];
    $zero = 0;
    $num_com_zero = $zero.$ddd.$celular ; 
    $num_s_zero = $ddd.$celular;

    $url = "http://201.76.188.6:8090/call.php?exten=7601&number=".$num_com_zero;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    print $output = curl_exec($ch);
    curl_close ($ch);
?>
  • 1

    i use php... is a limples api, where I send the information by link

  • @Pedrocastilho CURL is a PHP library aimed at data transfer through URL’s.

  • 1

    I modified my post by modifying your code for using Curl from a look if that’s what you want.

  • It worked, however, but my way, keeps changing to the page where it confirms that everything was done correctly... only that I did not want to change the page.. sera with that Curl you had put before, would solve?

  • From a research on Curl more precisely on CURLOPT_FOLLOWLOCATION. I hope to have helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.