Pgyer document center

Webhook Introduction

Webhook Function Introduction

Webhook is a way for users to change the behavior of Web applications by customizing the callback, and these callbacks can be maintained and modified by the third-party users or developers which are not official. You can customize some behavior notifications to specific URL via Webhook.

Developers can synchronize some of the event messages from AppGo to other platforms (or websites) by using the Webhook. For instance, when a developer uploads an App version or receives a feedback, AppGo will push the message to a specified URL created by this developer.

At present, AppGo supports the following two types of event:

  1. App Upload Event (including subsequent new version uploads)
  2. App New Feedback Event

Open Webhook in AppGo

First, enter My Apps and click an App name, then click Setting -> Webhook to check it’s setting status. It will directly display a page for you to create Webhook the first time you enter this page, as shown:

In the figure, follow the prompts to complete the details:

  • Webhook Name Name the Webhook you are going to create. For instance: WebhookTest.

  • URL Set the destination where the event messages are pushed when an event occurs. That means the URL receiving AppGo’s event. If it’s necessary to integrate services such as Cloud or HiWork, the URL must be provided by Cloud or HiWork.

  • Select Functions to Push Set what kinds of event messages should be pushed to the above-mentioned URL.

  • Webhook State You can turn the AppGo’s message push function on or off.

Click the “Save Info” button once you’ve filled in the information to create a Webhook. Thus, Pgyer will push the corresponding messages to the selected URL when an event occurs.

Notes and Debug Modes of Webhook

An App is allowed to have multiple Webhooks in AppGo, only need the developer to repeat the above process. But for the same App, you can only add up to three Webhooks.

If developer has his own Webhook services or just wants to test, Request service is recommended (http://request.lesschat.com/).

Third-party Webhook Service Development

For third-party Webhook services, AppGo uses HTTP POST request when sends events, Content-Type is application/json, and data format is JSON. For instance, when a new version is uploaded, the data format sent by AppGo is similar to the following form ( the actual situation will be little different ):

{
  "action": "App Update",
  "title": "OooPlay",
  "link": "http://www.pgyer.com/oooplay_test",
  "message": "Your App OooPlay has a new version (2.4) update.",
  "type": "updateVersion",
  "os_version": "2.4",
  "build_version": "139",
  "created": "2015-10-09 11:25:16",
  "updated": "2015-10-09 11:25:16",
  "timestamp": 1444361118,
  "appsize": "2238036",
  "device_type": 'iOS',
  "notes": "修复了一些小弱智的小bug"
}

When App receives a “Shake Feedback” message, the data format sent by AppGo is similar to the following form ( the actual situation will be little different ):

{
  "action": "App Feedback",
  "title": "OooPlay",
  "link": "http://www.pgyer.com/oooplay_test",
  "message": "Your App has received a new feedback message.",
  "type": "feedback",
  "os_version": "2.4",
  "build_version": "139",
  "created": "2015-10-09 11:25:16",
  "updated": "2015-10-09 11:25:16",
  "timestamp": 1444361118,
  "appsize": "2238036",
  "device_type": 'iOS',
  "notes": "Fixed some minor bugs."
}

When App receives a “Crash Log” message, the data format sent by AppGo is similar to the following form ( the actual situation will be little different ):

{
  "action": "Crash log",
  "title": "OooPlay",
  "link": "http://www.pgyer.com/oooplay_test",
  "message": "Your App OooPlay has received a new Crash Log message.",
  "type": "crashlog",
  "os_version": "2.4",
  "build_version": "139",
  "created": "2015-10-09 11:25:16",
  "updated": "2015-10-09 11:25:16",
  "timestamp": 1444361118,
  "appsize": "2238036",
  "device_type": 'iOS',
  "notes": "libsystem_kernel.dylib 0x3094c49c mach_msg_trap 20 CoreFoundation 0x21edf7f3 <redacted> 146 CoreFoundation 0x21edddb9 <redacted> 1016 ..."
}

Third-party Webhook Services can get message data by using the same way as getting POST RAW data. For instance, you can get data in the following ways in PHP:

Or:

$data = $HTTP_RAW_POST_DATA;

Carry out JSON DECODE after getting data to parse put the specific data, for instance: $info = json_decode($data, true);

$info = json_decode($data, true);

After that, the third-party Webhook services can process the received message data according to their own business logic, such as display the message flow or notification center in their own platforms.