0

Hi guys been trying to get WooCommerce to send customer details via API to PromoSoftware

Promosoftware api info

add_action('woocommerce_thankyou', 'send_order_to_ext'); 
function wdm_send_order_to_ext(  ){
$api = new RestClient(array(
'base_url' => "http://api.promosoftware.co.uk/v2/agdesignstudio/8461a78ff1abb7c4eea63dc7d9935e42", 
'format' => "php",
));
$addArray=array(


$addArray['ContactFirstName'] = 'Dave',
 $addArray['ContactLastName']='Davison',
 $addArray['ContactEmail']='dave@dave.com',
 $addArray['ContactSalutation']='Davo',
 $addArray['CompanyId']=12,//INT


$result=$api->post('contact',$addArray),
 json_decode($result->response),//returnsstdClassobject
 json_decode($result->response,true),//returnsassocarray
);
var_dump($result);
}

Im using php-restclient from github...

totally lost here.. just need to be guided in the right direction.

1

You have some syntax errors in your example code. Line endings should be ; Im sure you are aware. Your array declaration is missing the trailing ). Also using this library the format is appended to the url so this will fail, leave the format empty. This API only returns json anyway.

This should get you going:

add_action('woocommerce_thankyou', 'send_order_to_ext'); 
function wdm_send_order_to_ext(  ){
$api = new RestClient(array(
'base_url' => "http://api.promosoftware.co.uk/v2/youraccount/yourapikey", 
'format' => ""
));
    $addArray=array();
    $addArray['ContactFirstName'] = 'Dave';
    $addArray['ContactLastName']='Davison';
    $addArray['ContactEmail']='dave@dave.com';
    $addArray['ContactSalutation']='Davo';
    $addArray['CompanyId']=12;
    $result=$api->post('contact',$addArray);
    json_decode($result->response);//returnsstdClassobject
    json_decode($result->response,true);//returnsassocarray
    var_dump($result);
}

Would advise not publishing your private API key also

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.