I have the following code:
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => '[email protected]',
'subject' => 'testing from curl',
'html' => 'testing body',
'text' => 'testing body',
'from' => '[email protected]'
);
/* Put the below into a function */
$request = 'api url goes here';
$session = curl_init($request);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
print_r($response);
/* Put the above into a function */
Basically I want to put the above code between the comments into a function, so that I can set the params and then do the following:
sendthat($params);
This is to simply clean up my page, and have the curl request grabbing the array via a function.
How can I pass the array to a function?
curl_setoptcall).