0
私のcodeigniterプロジェクトにsmsテンプレートを登録するAPIを統合する必要があります。これは私のコードです:APIのコールバックURL
$postdata = array('userid' => 'user',
'password' => '[email protected]',
'template' => 'Demo template',
'callback_url' => base_url().'API/templateCallback'
);
$postdata = json_encode($postdata);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://example.com/TemplateRegistration2/registerTemplate.jsp");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec ($ch);
curl_close ($ch);
$response = json_decode($response);
print_r($response);
レスポンスはJSONオブジェクトのように、
{"req_id":"809ff62f-74a9-45a5-9cb5-5e60763289af","status":"0" ,"comment":"OK"}
になりますが、私は私のtemplateCallback()関数の中で、このJSONオブジェクトを読み込む方法について説明します。同じことを行う関数が組み込まれています