vendredi 4 novembre 2022

WhatsApp API integration in Laravel not working

I have issue in my laravel project, the code below is working fine in core php, but it's not workng in laravel

i'm using old laravel version 5.5

even not showing any error

please help me ASAP, i hava a deadline

please help me ASAP, i hava a deadline please help me ASAP, i hava a deadline

`if($request->has('whatsapp') && $request->whatsapp!=0){
                $url = "https://graph.facebook.com/v15.0/{key}/messages";

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('{auth key}', 'Content-Type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$data3 = [
  
    "type"=>"body",
    "parameters" => [
      "type"=>"text",
      "text" => "Mr Jibran"
    ]
];

$data2 = [
  "name"=>"sample_issue_resolution",
"language"=> ["code"=> "en_US" ],
"components" => $data3
];

/*
components:{
  type:body,
  parameters {
    type:text,
    text:Mr Jibran
  }}"

*/

$data = array(
  "messaging_product"=>"whatsapp",
  "to"=>"my number",
  "type"=>"template",
  "template"=> array(
    "name"=>"sample_issue_resolution",
    "language"=> array ("code"=> "en_US" ),
    "components" => array(
      ["type"=>"body",
    "parameters" => array(
      ["type"=>"text",
      "text" => "Mr Jibran"]
    )]
    )
  )
)
;



$fields_string = json_encode($data);

curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_string);

$resp = curl_exec($curl);
curl_close($curl);

echo $resp;
                
            }

        }

    }`


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire