Reply
Highlighted
Contributor
Posts: 10
Registered: ‎07-24-2014

New to integration - PHP cURL question

I am learning about working with integrating Authorize.net into my php application. Apparently I need to request and recieve a Token inorder to load a customer profile. I am not completely confident I have the right direction. Here's a cURL request I am trying:

 

*************

 

$Authorization = "PaymentProfileId=" . $someknownprofileid;
$URLBase = "https://secure.authorize.net/profile/editPayment";

 

function curl_request($url, $postdata) //single custom cURL request.
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url . "?" . $postdata,
CURLOPT_RETURNTRANSFER => true
));

$response = curl_exec($ch);
if (!curl_exec($ch)) {
// if curl_exec() returned false and thus failed
echo '<br>An error has occurred: ' . curl_error($ch). '<br>';
}
else {
echo '<br>everything was successful<br>';
}

echo "<br>cURL Get Info returns : <br>";
print_r(curl_getinfo($ch));

curl_close($ch);

return $response;
}

$data = curl_request($URLBase, $Authorization); //return cURL request to $data

//Display request result
echo "<br><br>cURL request returns : <br><br>";
var_dump($data);

 

***********

 This returns a 'Missing or Invalid Token' message. Since I am requesting for a token, I'm not sure how to proceed. Is this refering to the ProfileId I am passing? Am I not passing it correctly? Is this cURL soution the wrong way to go about this?

 

Thanks in advance for any assistance!

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: New to integration - PHP cURL question

[ Edited ]

Is in the doc

http://developer.authorize.net/api/cim/

 

getHostedProfilePage

 

And they have sample php code under the downloads. although there isn't one for getting the token