excatonline php联系人列表不会显示创建的用户帐户中的所有完整信息

时间:2017-11-13 12:49:35

标签: php exact-online picqer-exact-php-client

我试图获取“联系人”的数据,但我无法获得这些标签“AddressLine,City,FaxNumber,MiddelInitial,Note,State,ZipCode”

当我查看ExactOnline时,我看到了“联系”Voornaam,Tussenvoegsel,Achternaam,Functienaam,Telefoon,Mobiel,E-mail,这些都是我得到的输出(如果填写)。

然后我看得更远,我看到“Relatie”在这里是我想要的部分,但不能称之为。

我该如何解决这个问题?

class School < ApplicationRecord
  self.primary_key = :school_id
end

如果我运行php脚本,这是我得到的输出。

 ================================
           Exactonline         
           Connection          
 ================================

try {
        //Code
        for($i = 0; $i <1;) {
        //AddressLine2
        for($o = 0; $o <1;) {
        //BusinessPhone
        for($p = 0; $p <1;) {
        //City 
        for($q = 0; $q <1;) {
        //Country    
        for($w = 0; $w <1;) {
        //Created
        for($e = 0; $e <1;) {
        //Email
        for($r = 0; $r <1;) {
        //BusinessFax
        for($t = 0; $t <1;) {
        //FirstName
        for($y = 0; $y <1;) {
        //LastName
        for($u = 0; $u <1;) {
        //Initials
        for($a = 0; $a <1;) {
        //Mobile
        for($s = 0; $s <1;) {
        //Notes
        for($d = 0; $d <1;) {
        //Phone
        for($f = 0; $f <1;) {
        //State
        for($g = 0; $g <1;) {
        //Postcode
        for($h = 0; $h <1;) {

        $result = array();
        $contact = new \Picqer\Financials\Exact\Contact($connection);
        $result   = $contact->get();
        foreach ($result as $contact) {
        //Code
            ob_start();
            $i++;
            echo $result[]= $contact->Code;
            $filei[$i] = ob_get_contents();
            ob_end_clean();
            //echo $filei[$i]; //(Print available)
         //AddressLine2
            ob_start();
            $o++;
            echo $result[]= $contact->AddressLine2;
            $fileo[$o] = ob_get_contents();
            ob_end_clean();
            //echo $fileo[$o]; //(Print available)
          //BusinessPhone
            ob_start();
            $p++;
            echo $result[]= $contact->BusinessPhone;
            $filep[$p] = ob_get_contents();
            ob_end_clean();
            //echo $fileo[$p]; //(Print available)
          //City 
            ob_start();
            $q++;
            echo $result[]= $contact->City;
            $fileq[$q] = ob_get_contents();
            ob_end_clean();
            //echo $fileq[$q]; //(Print available)
          //Country
            ob_start();
            $w++;
            echo $result[]= $contact->Country;
            $filew[$w] = ob_get_contents();
            ob_end_clean();
            //echo $filea[$a]; //(Print available
         //Created
            ob_start();
            $e++;
            echo $result[]= $contact->Created;
            $filee[$e] = ob_get_contents();
            ob_end_clean();
            //echo $filee[$e]; //(Print available)  
        //Email
            ob_start();
            $r++;
            echo $result[]= $contact->Email;
            $filer[$r] = ob_get_contents();
            ob_end_clean();
            //echo $filer[$r]; //(Print available)
        //BusinessFax
            ob_start();
            $t++;
            echo $result[]= $contact->BusinessFax;
            $filet[$t] = ob_get_contents();
            ob_end_clean();
            //echo $filet[$t]; //(Print available)
       //FirstName
            ob_start();
            $y++;
            echo $result[]= $contact->FirstName;
            $filey[$y] = ob_get_contents();
            ob_end_clean();
            //echo $filey[$y]; //(Print available)
       //LastName
            ob_start();
            $u++;
            echo $result[]= $contact->LastName;
            $fileu[$u] = ob_get_contents();
            ob_end_clean();
            //echo $fileu[$u]; //(Print available)
       //Title
            ob_start();
            $a++;
            echo $result[]= $contact->Title;
            $filea[$a] = ob_get_contents();
            ob_end_clean();
            //echo $filea[$a]; //(Print available)
       //Mobile
            ob_start();
            $s++;
            echo $result[]= $contact->Mobile;
            $files[$s] = ob_get_contents();
            ob_end_clean();
            //echo $files[$s]; //(Print available)
       //Notes
            ob_start();
            $d++;
            echo $result[]= $contact->Notes;
            $filed[$d] = ob_get_contents();
            ob_end_clean();
            //echo $filed[$d]; //(Print available)
      //Phone
            ob_start();
            $f++;
            echo $result[]= $contact->Phone;
            $filef[$f] = ob_get_contents();
            ob_end_clean();
            //echo $filef[$f]; //(Print available)
       //State
            ob_start();
            $g++;
            echo $result[]= $contact->State;
            $fileg[$g] = ob_get_contents();
            ob_end_clean();
            //echo $fileg[$g]; //(Print available)
      //Postcode
            ob_start();
            $h++;
           echo $result[]= $contact->Postcode;
            $fileh[$h] = ob_get_contents();
            ob_end_clean();
            //echo $fileh[$h]; //(Print available)
                    }
                   }
                  }
                 }
                }
               }
              }
             }
            }
           }
          }   
         } 
        }
       } 
      }
     }  
    }
     //Witch contact 1,2,3,4,...
       $k = 1;
      //Code
       echo 'Code   = ' .$filei[1];
      //AddressLine2
      echo 'AddressLine   = ' .$fileo[$k];
      //BusinessPhone
      echo 'BusinessPhone = ' .$filep[$k];
      //City 
      echo 'City = ' .$fileq[$k];
      //Country
      echo 'Country = ' .$filew[$k];
      //Created
      echo 'created =  ' . $filee[$k];
      //Email
      echo 'Email = ' . $filer[$k];
      //BusinessFax
      echo 'BusinessFax  = ' . $filet[$k];
      //FirstName
      echo 'FirstName = ' .$filey[$k];
      //LastName
      echo 'Your last name = ' .$fileu[$k];
      //Initials
      echo 'Title = ' .$filea[$k];
      //Mobile
      echo 'Mobile = ' . $files[$k];
      //Notes
      echo 'Notes = ' .  $filed[$k];
      //Phone
      echo 'Phone = ' .  $filef[$k];
      //State
      echo 'State = ' .  $fileg[$k];
      //Postcode
      echo 'Postcode = ' . $fileh[$k];



        json_encode($result);
    } catch (\Exception $e) {
        json_encode(array(get_class($e) . ' : ' . $e->getMessage()));
    }

   =====================================
                   Autotask              
                 Connection            
    =====================================
    require_once 'C:\xampp\htdocs\Api\Autotask\vendor\autoload.php';
    $username = '++++++++++++++++++++++++++++++++++++++';
    $password = '++++++++++++++++';

    $contact= new ATWS\AutotaskObjects\Contact();
    $contact->id = 0; //0 for new and ID for update
    $contact->AccountID = 236;
    $contact->AlternatePhone = $filep[$k];
    $contact->Country = $filew[$k];
    $contact->CreatDate = $filee[$k];
    $contact->EMailAddress = $filer[$k];
    $contact->FirstName = $filey[$k];
    $contact->LastName = $fileu[$k];
    $contact->MobilePhone = $files[$k];
    $contact->Phone = $filef[$k];
    $contact->Active = '0';

    //$contact->AddressLine = $fileo[$k];+
    //$contact->City = $fileq[$k];+
    //$contact->FaxNumber = $filet[$k];+
    //$contact->MiddleInitial = $filea[$k];+
    //$contact->Note = $filed[$k];+
    //$contact->State = $fileg[$k];+
    //$contact->ZipCode = $fileh[$k];+
    echo "Auotask client created";


    $authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
    $opts = array('trace' => 1);
    $client = new ATWS\Client($authWsdl, $opts);
    $zoneInfo = $client->getZoneInfo($username);

    $authOpts = array(
        'login' => $username,
        'password' => $password,
        'trace' => 1,   // Allows us to debug by getting the XML requests sent
    );
    $wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
    $client = new ATWS\Client($wsdl, $authOpts);

    print_r($client->create($contact));

我想在输出中获得完整的用户信息。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

for($i=0;$i<1;){...}相当于$i=0; while($i<1){...},因此您应该确保在某些时候$i的值发生变化,然后离开循环。

在您的情况下,如果$result = $contact->get();返回空列表,则您无法输入foreach,因此您永远不会使用$x++到达部分(替换{{1}使用您在嵌套x循环中使用的任何 one-char 变量。)

您通常会在for的第三个输入中添加$i++,或者您可以添加其他条件,例如:

for

所以循环将一直运行到$iterations=0; for($i=0; $i<1 && $iterations<50; $iterations++) { ... } $i >= 1 这意味着除非您更改$iterations >= 50&#39;循环中的值,它将最多50次

如果您希望输入在某个时刻发生变化,但如果您真的只想获得一个输入,则根本不应该使用$iterations循环,而只是删除所有这些循环,删除所有for(在所有 one-char 变量名中使用x)并仅使用一个初始化为$x++;的变量。

同样,以可理解的方式命名变量被认为是一种好习惯。

注意: 以上内容中没有任何内容是特定于PHP的,这是算法 - 大多数编程语言都很常见。