Google PHP API客户端和Fusion Tables:如何使用importRows? [英] Google PHP API Client & Fusion Tables: How to use importRows?

查看:52
本文介绍了Google PHP API客户端和Fusion Tables:如何使用importRows?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google API php Client的0.6.3版似乎支持importRows命令:

Version 0.6.3 of the Google API php Client appears to support the importRows command:

public function importRows($tableId, $optParams = array()) {
  $params = array('tableId' => $tableId);
  $params = array_merge($params, $optParams);
  $data = $this->__call('importRows', array($params));
  if ($this->useObjects()) {
    return new Google_Import($data);
  } else {
    return $data;
  }
}

importRows 文档与该功能已在php Client中实现的方式,因为似乎也没有地方可以传递CSV信息.

The importRows documentation doesn't really coincide with the way the function has been implemented in the php Client, as there doesn't appear to be anywhere to pass the CSV information too.

有人使用Google API php Client 0.6.3成功实现importRows的示例代码吗?

Does anyone have any example code using the Google API php Client 0.6.3 successfully implementing importRows?

我让我的实现与一个服务帐户一起工作,每次输入一行.显然,我宁愿批量执行此操作,而不是遍历插入"或"sql".

I have my implementation working with a service account entering one row at a time. Obviously I'd prefer to do it in bulk rather than loop through an 'insert' or 'sql'.

推荐答案

我知道这是一个较晚的答复,但是为了将来参考,无论如何我都会答复: 您需要在optParams数组上使用 uploadType mimeType 数据.

I know this is a late reply, but for future reference, I will reply it anyway: You need to use the uploadType, mimeType and data on the optParams array.

示例:

importRows( [tableId], array(
 'uploadType' =>  'media' ,
 'mimeType' => 'application/octet-stream' ,
 'data'=>'1,Moth, 30, 2012')
);

这篇关于Google PHP API客户端和Fusion Tables:如何使用importRows?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆