Community
Showing results for 
Search instead for 
Do you mean 
Reply

Probleme on Adding Contact Using IE on ACT WEB API Version: 1.0.267.0

New Member
Posts: 3
Country: France

Probleme on Adding Contact Using IE on ACT WEB API Version: 1.0.267.0

 

Hello , 

im tryinng  To add a contact Using the ACT WEB API . i Get variable threw "GET" METHOD FROM AN URL Given  By another Web Application Running only on IE (INTERNET EXPLORER ) .my problem is when i try to add a contact using IE BRowser  I get this RESPONSE FROM THE SERVER :

 

NULL string(0) "" string(45) "{ "note.contacts[0].id": [ "" ] }"

 

WHEN I USE ANOTHER BROWSERl like GOOGLE CHROME  i get an normal response and i found my contact in my ACT Data base  

 

this is my code : 

<?php
//ADDING CONTACT 



extract($_GET);

$username=$Agent;
$passwd=$Password;
$toencode=$username.':'.$passwd;
$auth=base64_encode($toencode);

/*
echo session_status();
if (session_status()==1) 
  session_start();
echo session_status();

if ($_SESSION["barrer"] == NULL)
{
  $token=get_barrer($auth);
  $_SESSION["barrer"] = $token;

}


*/



function get_barrer($auth)
{

 
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://192.168.1.105/act.web.api/authorize");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");


$headers = array();
$headers[] = "Authorization: Basic ".$auth;
$headers[] = "Act-Database-Name: WBCC_GROUP";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return $result;
}

$barrer=get_barrer($auth);
echo "<p> $barrer </p>";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://192.168.1.105/act.web.api/api/Contacts");
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

$headers = array(
'Authorization: Bearer ' .$barrer,
'Content-type: application/json'
);
var_dump($_SESSION["barrer"]);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$addcontact= array
  (
    "fullName" => $fullname,
    "emailAddress" => $email,
    "mobilePhone" => $mobile,
    "businessPhone" => $tel ,
    "website" =>$site_int,
    "faxPhone" => $fax,
    "businessAddress" => array(
    "line1" => $adresse,
    "city" => $ville,
    "postalCode" =>$cp,
    "country"=> "France"
    ),
    "customFields" => array(
      "code naf" => $codenaf,
       "siret" => $siret,
      "statut" => $status,
     "secteur d'activité bd" => $Activite,
      "effectif" => $effectif
    )



);


$json = json_encode($addcontact);

curl_setopt($ch, CURLOPT_POSTFIELDS, $json);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);



$convert_result=json_decode($result,true);

$id_contact=$convert_result["id"];
if (isset($id_contact)) $affichage="Ficher Inseree sur ACT AVEC SUCCES "; else 
 $affichage="Probleme servenue lors de la communication avec APi ( Essaye de rinserer la fiche ) "; 

$ch1 = curl_init();

curl_setopt($ch1, CURLOPT_URL, "http://192.168.1.105/act.web.api/api/Notes");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_POSTFIELDS, "{\n \n  \"noteText\": \"$commentaire\",\n  \n  \"contacts\": [\n    {\n      \"id\": \"$id_contact\",\n    \n    }\n  ]\n}");
curl_setopt($ch1, CURLOPT_POST, 1);

curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);

$result1 = curl_exec($ch1);
if (curl_errno($ch1)) {
    echo 'Error:' . curl_error($ch1);
}
curl_close ($ch1);
var_dump($result);
var_dump($result1);


?>


 

Administrator
Posts: 1,312
Country: United_Kingdom

Re: Probleme on Adding Contact Using IE on ACT WEB API Version: 1.0.267.0

If you are getting a correct response on one browser, and not on another - it's likely that the issue doesn't come from the response itself but they way your code is interpreting the response. I can't help you with your php script unfortunately, but I'd start by making sure the raw response from the server is as expected before it's handled in anyway.