Php google prediction v 1.6 trainedmodels.update函数添加一些空值

Php google prediction v 1.6 trainedmodels.update函数添加一些空值,php,google-api-php-client,google-prediction,Php,Google Api Php Client,Google Prediction,我尝试使用谷歌预测API,我通过API调用添加了一个新模型,现在我尝试通过API更新调用来训练它。 我设法更新了它,但由于某些原因,某些数据丢失,例如,当我运行trainedmodels.analyze时,通过Google API的浏览器,我看到一些值为空: { "kind": "prediction#analyze", "id": "my_model_id", "dataDescription": { "outputFeature": { "text": [ {

我尝试使用谷歌预测API,我通过API调用添加了一个新模型,现在我尝试通过API更新调用来训练它。 我设法更新了它,但由于某些原因,某些数据丢失,例如,当我运行trainedmodels.analyze时,通过Google API的浏览器,我看到一些值为空:

{
 "kind": "prediction#analyze",
 "id": "my_model_id",
 "dataDescription": {
  "outputFeature": {
   "text": [
    {
     "value": "lost",
     "count": "1"
    },
    {
     "value": "won",
     "count": "4"
    }
   ]
  },
  "features": [
   {
    "index": "0",
    "text": {
     "count": "5"
    }
   },
   {
    "index": "1",
    "categorical": {
     "count": "5",
     "values": [
      {
       "value": "google",
       "count": "3"
      },
      {
       "value": "mobile",
       "count": "2"
      }
     ]
    }
   },
   {
    "index": "2",
    "categorical": {
     "count": "5",
     "values": [
      {
       "value": "google",
       "count": "2"
      },
      {
       "value": "organic",
       "count": "3"
      }
     ]
    }
   },
   {
    "index": "3",
    "text": {
     "count": "5"
    }
   },
   {
    "index": "4",
    "text": {
     "count": "5"
    }
   },
   {
    "index": "5",
    "text": {
     "count": "2"
    }
   }
  ]
 }
}
我通过Google PHP客户端打电话,如下所示:

 private function updateModel($ga_details,$label,$model_name)
    {
        $csv_instance = [];
        $csv_instance[0] = $ga_details['user_type'];
        $csv_instance[1] = $ga_details['device_category'];
        $csv_instance[2] = $ga_details['source'];
        $csv_instance[3] = $ga_details['campaign'];
        $csv_instance[4] = $ga_details['medium'];
        $csv_instance[5] = $ga_details['ad_group'];
        try{
            $prediction = new \Google_Service_Prediction($this->client);
            $update = new \Google_Service_Prediction_Update();
            $update->setCsvInstance($csv_instance);
            $update->setOutput($label);
            $res = $prediction->trainedmodels->update(config('prediction.PROJECT_ID'),$model_name,$update);
            return ($res && $res->id) ? $res->id : false;
        }catch (\Google_Service_Exception $e){
            return Response::json([
                'custom' => 'could not updateModel',
                'message' => $e->getMessage(),
                'code'    => $e->getCode(),
                'errors'  => $e->getErrors()
            ]);
        }
    }
$ga_details
的值由我预先定义(用于测试):

你知道为什么在我的模型中,
user\u type,medium和ad\u group
是空的吗?(我试图取下()并在空白处trin,但没有效果)。

解决了

有趣的是,我总是发现自己在自言自语,但如果我能帮助别人,为什么不呢?:) 我使用PHP
urlencode()
方法对传入的值进行编码,解决了这个问题

$ga_details = [
            "user_type"       => "Returning Visitor",
            "device_category" => "mobile",
            "source"          => "google",
            "campaign"        => "organic",
            "medium"          => "(not set)",
            "ad_group"        => "(not set)",
        ];