【问题标题】:Integrate Mpesa API with google forms将 Mpesa API 与谷歌表单集成
【发布时间】:2016-05-09 07:27:25
【问题描述】:

我想将 Mpesa API 集成到谷歌表单。 用户使用表单支付,我们说注册费

【问题讨论】:

标签: google-apps-script mpesa


【解决方案1】:

您现在使用可通过 Safaricom 的developer portal 访问的 M-Pesa RESTful API。 documentation 包含主要编程语言的示例代码 - Python、JavaScript/NodeJS、Java、Ruby。

您现在可以像使用任何其他 RESTful API 一样使用 Google Apps 脚本使用 M-Pesa RESTful API。

【讨论】:

  • 非常感谢。 JSON 请求现在是上帝发送的
  • 不客气。如果您对 M-Pesa API 有任何疑问,请将其发送至 apifeedback@safaricom.co.ke。
【解决方案2】:

我认为这可以通过使用 Apps 脚本创建一个 google 表单来实现。

表单服务

此服务允许脚本创建、访问和修改 Google 表单。

这是使用 Apps 脚本创建 Google 表单的示例代码。

// Create a new form, then add a checkbox question, a multiple choice question,
// a page break, then a date question and a grid of questions.
var form = FormApp.create('New Form');
var item = form.addCheckboxItem();
item.setTitle('What condiments would you like on your hot dog?');
item.setChoices([
        item.createChoice('Ketchup'),
        item.createChoice('Mustard'),
        item.createChoice('Relish')
    ]);
form.addMultipleChoiceItem()
    .setTitle('Do you prefer cats or dogs?')
    .setChoiceValues(['Cats','Dogs'])
    .showOtherOption(true);
form.addPageBreakItem()
    .setTitle('Getting to know you');
form.addDateItem()
    .setTitle('When were you born?');
form.addGridItem()
    .setTitle('Rate your interests')
    .setRows(['Cars', 'Computers', 'Celebrities'])
    .setColumns(['Boring', 'So-so', 'Interesting']);
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());

然后您可以在 Apps Scripts 中集成第三方 API。

外部 API

Google Apps 脚本可以与来自整个网络的 API 进行交互。本指南展示了如何在脚本中使用不同类型的 API。

Apps Script 中提供了数十种 Google API,例如 built-in servicesadvanced services。如果您想使用不能作为 Apps 脚本服务提供的 Google(或非 Google)API,您可以通过 URL Fetch service 连接到 API 的公共 HTTP 接口。

以下示例向 YouTube API 发出请求并返回与查询 skateboarding dog 匹配的视频供稿。

var url = 'https://gdata.youtube.com/feeds/api/videos?'
    + 'q=skateboarding+dog'
    + '&start-index=21'
    + '&max-results=10'
    + '&v=2';
var response = UrlFetchApp.fetch(url);
Logger.log(response);

同样,以下示例将视频上传到 YouTube。也使用UrlFetchApp.fetch()

var payload = 'XXXXX'; // Replace with raw video data.
var headers = {
    'GData-Version': '2',
    'Slug': 'dog-skateboarding.mpeg'
    // Add any other required parameters for the YouTube API.
};
var url = 'https://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
var options = {
    'method': 'post',
    'headers': headers,
    'payload': payload
};
var response = UrlFetchApp.fetch(url, options);

【讨论】:

    【解决方案3】:

    请在此处查看我对与您的类似问题的回答:Intergrating Mobile Money like Mpesa and AirtelMoney with Android App

    探索使用定制的 Mpesa api 开发 Android 应用程序的可能性,以帮助您在线存储 Mpesa 消息并优化该信息以在 Google 表单上使用

    【讨论】:

      猜你喜欢
      • 2015-11-26
      • 1970-01-01
      • 2012-08-21
      • 2018-01-26
      • 2020-04-14
      • 1970-01-01
      • 2019-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多