Return of content by Curl

Asked

Viewed 1,863 times

0

I’m developing an automatic billet generator, using a tool provided by Banrisul Bank. To generate this automatic ticket I need to send a request through the following URL: https://ww8.banrisul.com.br/brb/link/Brbw2Lhw_Bloqueto_Titulos_Internet.aspx

The data I reported on this link are fictitious, I wonder what is the best way to get the return of this boleto generated automatically by Curl? How can I make the boleto be opened in a way that facilitates printing?

Thank you.

  • Well, you’ll get a little tricky in this case, because the contents of the billet itself is generated in a frame and called by JS. If you simply get the result of Curl, you will not get the billet.

  • @Bacco the right one would create a pop-up then?

  • 1

    Difficult to say what is best in this case, depends on the application. When in doubt, just provide a link/button and put a warning below saying that the user will be directed to the bank system. Some things don’t make it right.

  • @Bacco I understand, I tried in several ways to get an answer to this problem, because the Manager requested something other than what has to be done. So my question here at Stackoverflow.

  • 1

    Explain to him that the site uses a javascript-generated frame, etc... (maybe he doesn’t understand and gives up complicating :) )

  • @Bacco will have to be that way. Thanks for the help

  • To read the page that runs Javascript to be generated I once used this lib https://github.com/mikehaertl/phpwkhtmltopdf.

  • Why is my question too broad?

  • Take the action of the form, and the fields that the form has. Mount a CURL with the exact same content. Inspecting the element and checking the network tab can help you see what the current form sends and where it sends Try using the network tab of the browser, and see all the actions the page does, and

Show 4 more comments

3 answers

2

If I understand correctly you are asking how do you get the return from Curl. In this case I recommend you to use the function curl_setopt, passing through parameter:

  • The Curl connection
  • The CURLOPT_RETURNTRANSFER option
  • 1 or true

Passing these options you tell Curl that the url return should come back to you when you invoke the function curl_exec instead of being displayed directly in the browser.

  • You are returning me an empty array, which may be?

  • There’s probably been some mistake. To test for errors try the following: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, ... OPTIONS I WANT TO CONFIGURE.... ); $return = curl_exec($ch); $error = curl_errno($ch); $erroMsg = curl_error($ch);

2

Be careful with the CURLOPT_SSL_VERIFYPEER it be set to true to check the secure connection (already suffered a lot with this).

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

Second, to display this ai with Curl just retrieve the answer from curl_exec and print it for your users. I think you should not change the print option that the bank already offers, it is good and works well in any browser.

  • My answer is coming empty, what could cause it? ?

1

About printing, Banrisul already provides a link on the page generated with this functionality.

In your case, I would open the link in a pop-up and let the person click the print.

  • The idea is to have an option to confirm registration and print/send by email the boleto, so I commented on only take the boleto.

Browser other questions tagged

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