Guest User

Untitled

a guest
Oct 2nd, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. $user = 'xxxxxxxxxxxxxxxxxxxxxxxx';
  2. $pass = '';
  3. $data = array(
  4. "email" => "Baralho@gmail.com",
  5. "due_date" => "2018-10-08",
  6. "items" => array(
  7. "description"=>"carro",
  8. "quantity"=> 1,
  9. "price_cents"=>150000
  10. ),
  11. "payer"=>array(
  12. "cpf_cnpj"=>"644.620.920-74",
  13. "name"=>"Jeison",
  14. "phone_prefix"=>"31",
  15. "phone"=>"991872520",
  16. "address"=>array(
  17. "zip_code"=>"30520240",
  18. "number"=>"109",
  19. "street"=>"blenda"
  20. )
  21. )
  22. );
  23. $data_string=json_encode($data);
  24. $ch = curl_init();
  25. curl_setopt( $ch, CURLOPT_URL, 'https://api.iugu.com/v1/invoices/' );
  26. curl_setopt( $ch, CURLOPT_HEADER, 1 );
  27. curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . base64_encode( $user . ':' . $pass ) ) );
  28. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  29. curl_setopt($ch,CURLOPT_POST, TRUE);
  30. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  31. $return=curl_exec( $ch );
  32. curl_close( $ch );
  33. header("Content-Type: text/json; charset=utf8");`
  34.  
  35. //demais itens omitidos
  36. $data = array(
  37. "items" => array(
  38. array(
  39. "description"=>"carro",
  40. "quantity"=> 1,
  41. "price_cents"=>150000
  42. )
  43. )
  44. );
  45.  
  46. //demais itens omitidos
  47. $data = array(
  48. "items" => [
  49. [
  50. "description"=>"carro",
  51. "quantity"=> 1,
  52. "price_cents"=>150000
  53. ]
  54. ]
  55. );
Add Comment
Please, Sign In to add comment