Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Chunlei Wang authored Feb 26, 2017
1 parent 36855ca commit 83a8cd7
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
# facebook-messenger
A most easily usable Facebook Messenger Platform API

# Usage

```xml
<dependency>
<groupId>com.github.codedrinker</groupId>
<artifactId>facebook-messenger</artifactId>
<version>1.0.0</version>
</dependency>
```
## Use FMClicent.getInstance() to obtain API Instance.

```java
FMClient fmClient = FMClient.getInstance();
```
## Use with* methods to set parameters to FMClient instance.

```java
public class FMPPostbackHandler extends FMMessagePostBackHandler {
@Override
public void handle(FMReceiveMessage.Messaging message) {
log.debug("FMPPostbackHandler handlePostBack, sender -> {}, postback -> {}", message.getSender(), message);
}
}
```
```java
FMClient fmClient = FMClient.getInstance();
FMPPostbackHandler fmpPostbackHandler = new FMPPostbackHandler();
fmClient.withAccessToken("token")
.withAccessSecret("secret")
.withFmMessagePostBackHandler(fmpPostbackHandler);
```
## Use signature method to valid the payload.

```java
StringBuilder buffer = new StringBuilder();
BufferedReader reader = request.getReader();
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
String payload = buffer.toString();
fmClient.signature(payload, xHubSignature);
```
## Use dispatch method to dispatch payload message.

```java
fmClient.dispatch(payload);
```

# Road Map
1.0.0

Expand All @@ -17,4 +66,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.

0 comments on commit 83a8cd7

Please sign in to comment.