1

我调用了这样的 API:

$service = new Class_Service();

$parameters = new GetClasses();
$parameters->Request = new GetClassesRequest();

$parameters->Request->SourceCredentials = new SourceCredentials();
$parameters->Request->SourceCredentials->SourceName = "Name";
$parameters->Request->SourceCredentials->Password = "Pass";
$parameters->Request->SourceCredentials->SiteIDs = array(
12
);

$classes = $service->GetClasses($parameters);

var_dump($classes);

并收到这样的回复:

object(GetClassesResponse)#7 (1) { 
  ["GetClassesResult"]=> 
    object(GetClassesResult)#8 (6 {
      ["Classes"]=> 
        object(stdClass)#9 (1) { 
          ["Class"]=> array(25) { 
            [0]=> object(Mi_Class)#10 (21) {
               ["ClassScheduleID"]=> int(15)
               ["Visits"]=> NULL
               ["Clients"]=> NULL 
               ["Location"]=> object(Location)#11 (30) { 
                 ["BusinessID"]=> NULL
                 ["SiteID"]=> int(12)
                 ["BusinessDescription"]=> NULL
                 ["AdditionalImageURLs"]=> object(stdClass)#12 (0) { }
                 ["FacilitySquareFeet"]=> NULL

响应通常看起来像这样吗?如何以格式化的方式获取数据?

4

1 回答 1

1

你可以像这样遍历你的类:

foreach ($classes->GetClassesResult->Classes->Class as $class) {
    // ... do your stuff here
    print_r($class);
}
于 2013-03-24T18:57:01.930 回答