Skip to content

Commit 78c73f3

Browse files
committed
Converting to .NET Core (Standard)
1 parent 956ff97 commit 78c73f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+216
-1447
lines changed

README.md

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -138,131 +138,7 @@ namespace WebApiSample.AspNetCore.Controllers
138138
}
139139
```
140140

141-
### Usage - Webhook for WebAPI Full Framework .NET 4.6.1
142141

143-
```powershell
144-
Install-Package ReflectSoftware.Facebook.Messenger.WebAPI.Webhook
145-
```
146-
147-
```csharp
148-
using ReflectSoftware.Facebook.Messenger.Client;
149-
using ReflectSoftware.Facebook.Messenger.Common.Models.Client;
150-
using ReflectSoftware.Facebook.Messenger.WebAPI.Webhook;
151-
using ReflectSoftware.Insight;
152-
using System.Threading.Tasks;
153-
using System.Web.Http;
154-
155-
namespace WebApiSample.Controllers
156-
{
157-
/// <summary>
158-
///
159-
/// </summary>
160-
/// <seealso cref="System.Web.Http.ApiController" />
161-
public class ChatterController : ApiController
162-
{
163-
private readonly WebhookHandler _webHookHandler;
164-
private readonly ClientMessenger _clientMessenger;
165-
166-
/// <summary>
167-
/// Initializes a new instance of the <see cref="ChatterController"/> class.
168-
/// </summary>
169-
public ChatterController()
170-
{
171-
_webHookHandler = new WebhookHandler();
172-
_webHookHandler.VerificationToken = "your_verification_code";
173-
_clientMessenger = new ClientMessenger("your_page_access_token");
174-
}
175-
176-
/// <summary>
177-
/// Receives the asynchronous.
178-
/// </summary>
179-
/// <param name="id">The identifier.</param>
180-
/// <returns></returns>
181-
[AllowAnonymous]
182-
[HttpPost, HttpGet]
183-
[Route("api/chatter/receive/{id}")]
184-
public async Task<IHttpActionResult> ReceiveAsync(string id)
185-
{
186-
var result = (IHttpActionResult)null;
187-
188-
switch (id)
189-
{
190-
case "fbmessager":
191-
result = await FacebookAsync();
192-
break;
193-
}
194-
195-
return result ?? BadRequest();
196-
}
197-
198-
#region Facebook
199-
/// <summary>
200-
/// Facebook the asynchronous.
201-
/// </summary>
202-
/// <returns></returns>
203-
private async Task<IHttpActionResult> FacebookAsync()
204-
{
205-
return await _webHookHandler.HandleAsync(Request, async (callback) =>
206-
{
207-
RILogManager.Default.SendJSON("Facebook.Callback", callback);
208-
209-
foreach (var entry in callback.Entry)
210-
{
211-
foreach (var messaging in entry.Messaging)
212-
{
213-
if (messaging.Message != null && !messaging.Message.IsEcho)
214-
{
215-
/// User Send Message
216-
/// This callback will occur when a message has been sent to your page.You may receive text messages or messages
217-
/// with attachments(image, audio, video, file or location).Callbacks contain a seq number which can be used
218-
/// to know the sequence of a message in a conversation. Messages are always sent in order.
219-
/// You can subscribe to this callback by selecting the message field when setting up your webhook.
220-
221-
var userProfile = await _clientMessenger.GetUserProfileAsync(messaging.Sender.Id);
222-
RILogManager.Default.SendJSON("userProfile", userProfile);
223-
224-
var result = await _clientMessenger.SendMessageAsync(messaging.Sender.Id, new TextMessage
225-
{
226-
Text = $"Hi, {userProfile.Firstname}. An agent will respond to your question shortly."
227-
});
228-
229-
RILogManager.Default.SendJSON("Results", new[] { result });
230-
}
231-
else if (messaging.Postback != null)
232-
{
233-
}
234-
else if (messaging.Delivery != null)
235-
{
236-
/// This callback will occur when a message a page has sent has been delivered.
237-
/// You can subscribe to this callback by selecting the message_deliveries field when setting up your webhook.
238-
}
239-
else if (messaging.Read != null)
240-
{
241-
/// This callback will occur when a message a page has sent has been read by the user.
242-
/// You can subscribe to this callback by selecting the message_reads field when setting up your webhook.
243-
}
244-
else if (messaging.Optin != null)
245-
{
246-
/// User Call "Message Us"
247-
}
248-
else if (messaging.Referral != null)
249-
{
250-
/// Referral
251-
}
252-
else if (messaging.AccountLinking != null)
253-
{
254-
/// Account Linking
255-
}
256-
}
257-
}
258-
259-
return Ok();
260-
});
261-
}
262-
#endregion Facebook
263-
}
264-
}
265-
```
266142

267143
Copyright &copy; 2017 ReflectSoftware Inc. - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).
268144

ReflectSoftware.Facebook.sln

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,54 @@ VisualStudioVersion = 15.0.26430.13
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01. Solution Items", "01. Solution Items", "{1022C351-7255-4314-9756-58D352F94F23}"
77
ProjectSection(SolutionItems) = preProject
8+
appveyor.yml = appveyor.yml
9+
build.ps1 = build.ps1
810
README.md = README.md
9-
src\ReflectSoftware.Facebook.licenseheader = src\ReflectSoftware.Facebook.licenseheader
10-
src\VersionInfo.cs = src\VersionInfo.cs
11+
header\ReflectSoftware.Facebook.licenseheader = header\ReflectSoftware.Facebook.licenseheader
1112
EndProjectSection
1213
EndProject
1314
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02. src", "02. src", "{25FE0F58-B25F-4164-821F-B754C13F0F52}"
1415
EndProject
1516
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03. samples", "03. samples", "{9DB65601-A628-4E1B-A51E-619119068806}"
1617
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectSoftware.Facebook.Messenger.Common", "src\ReflectSoftware.Facebook.Messenger.Common\ReflectSoftware.Facebook.Messenger.Common.csproj", "{EEC96650-8114-4973-A2F5-A60B7091F4BD}"
18-
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectSoftware.Facebook.Messenger.Client", "src\ReflectSoftware.Facebook.Messenger.Client\ReflectSoftware.Facebook.Messenger.Client.csproj", "{A83998BC-F38A-4EA5-BC3D-562C543C3AE1}"
20-
EndProject
2118
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReflectSoftware.Facebook.Messenger.AspNetCore.Webhook", "src\ReflectSoftware.Facebook.Messenger.AspNetCore.Webhook\ReflectSoftware.Facebook.Messenger.AspNetCore.Webhook.csproj", "{B8B63F4C-FE42-4233-A5EB-B9B47775E954}"
2219
EndProject
23-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectSoftware.Facebook.Messenger.WebAPI.Webhook", "src\ReflectSoftware.Facebook.Messenger.WebAPI.Webhook\ReflectSoftware.Facebook.Messenger.WebAPI.Webhook.csproj", "{85CA75A0-678C-4E80-8B16-943DB0EB5CD4}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApiSample.AspNetCore", "samples\WebApiSample.AspNetCore\WebApiSample.AspNetCore.csproj", "{353987F0-CC4F-4ED9-8803-16E515D49A67}"
2421
EndProject
25-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiSample", "samples\WebApiSample\WebApiSample.csproj", "{F39E65D7-EC3D-45FB-BD78-73CE1A984CAC}"
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReflectSoftware.Facebook.Messenger.Client", "src\ReflectSoftware.Facebook.Messenger.Client\ReflectSoftware.Facebook.Messenger.Client.csproj", "{DA56834D-5F42-4DB4-B000-668A757B02F2}"
2623
EndProject
27-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApiSample.AspNetCore", "samples\WebApiSample.AspNetCore\WebApiSample.AspNetCore.csproj", "{353987F0-CC4F-4ED9-8803-16E515D49A67}"
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReflectSoftware.Facebook.Messenger.Common", "src\ReflectSoftware.Facebook.Messenger.Common\ReflectSoftware.Facebook.Messenger.Common.csproj", "{01E7AE57-068D-4F5A-B141-4A01CDB74F52}"
2825
EndProject
2926
Global
3027
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3128
Debug|Any CPU = Debug|Any CPU
3229
Release|Any CPU = Release|Any CPU
3330
EndGlobalSection
3431
GlobalSection(ProjectConfigurationPlatforms) = postSolution
35-
{EEC96650-8114-4973-A2F5-A60B7091F4BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36-
{EEC96650-8114-4973-A2F5-A60B7091F4BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
37-
{EEC96650-8114-4973-A2F5-A60B7091F4BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
38-
{EEC96650-8114-4973-A2F5-A60B7091F4BD}.Release|Any CPU.Build.0 = Release|Any CPU
39-
{A83998BC-F38A-4EA5-BC3D-562C543C3AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40-
{A83998BC-F38A-4EA5-BC3D-562C543C3AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
41-
{A83998BC-F38A-4EA5-BC3D-562C543C3AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
42-
{A83998BC-F38A-4EA5-BC3D-562C543C3AE1}.Release|Any CPU.Build.0 = Release|Any CPU
4332
{B8B63F4C-FE42-4233-A5EB-B9B47775E954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4433
{B8B63F4C-FE42-4233-A5EB-B9B47775E954}.Debug|Any CPU.Build.0 = Debug|Any CPU
4534
{B8B63F4C-FE42-4233-A5EB-B9B47775E954}.Release|Any CPU.ActiveCfg = Release|Any CPU
4635
{B8B63F4C-FE42-4233-A5EB-B9B47775E954}.Release|Any CPU.Build.0 = Release|Any CPU
47-
{85CA75A0-678C-4E80-8B16-943DB0EB5CD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48-
{85CA75A0-678C-4E80-8B16-943DB0EB5CD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
49-
{85CA75A0-678C-4E80-8B16-943DB0EB5CD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
50-
{85CA75A0-678C-4E80-8B16-943DB0EB5CD4}.Release|Any CPU.Build.0 = Release|Any CPU
51-
{F39E65D7-EC3D-45FB-BD78-73CE1A984CAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52-
{F39E65D7-EC3D-45FB-BD78-73CE1A984CAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
53-
{F39E65D7-EC3D-45FB-BD78-73CE1A984CAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
54-
{F39E65D7-EC3D-45FB-BD78-73CE1A984CAC}.Release|Any CPU.Build.0 = Release|Any CPU
5536
{353987F0-CC4F-4ED9-8803-16E515D49A67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5637
{353987F0-CC4F-4ED9-8803-16E515D49A67}.Debug|Any CPU.Build.0 = Debug|Any CPU
5738
{353987F0-CC4F-4ED9-8803-16E515D49A67}.Release|Any CPU.ActiveCfg = Release|Any CPU
5839
{353987F0-CC4F-4ED9-8803-16E515D49A67}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{DA56834D-5F42-4DB4-B000-668A757B02F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{DA56834D-5F42-4DB4-B000-668A757B02F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{DA56834D-5F42-4DB4-B000-668A757B02F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{DA56834D-5F42-4DB4-B000-668A757B02F2}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{01E7AE57-068D-4F5A-B141-4A01CDB74F52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{01E7AE57-068D-4F5A-B141-4A01CDB74F52}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{01E7AE57-068D-4F5A-B141-4A01CDB74F52}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{01E7AE57-068D-4F5A-B141-4A01CDB74F52}.Release|Any CPU.Build.0 = Release|Any CPU
5948
EndGlobalSection
6049
GlobalSection(SolutionProperties) = preSolution
6150
HideSolutionNode = FALSE
6251
EndGlobalSection
6352
GlobalSection(NestedProjects) = preSolution
64-
{EEC96650-8114-4973-A2F5-A60B7091F4BD} = {25FE0F58-B25F-4164-821F-B754C13F0F52}
65-
{A83998BC-F38A-4EA5-BC3D-562C543C3AE1} = {25FE0F58-B25F-4164-821F-B754C13F0F52}
6653
{B8B63F4C-FE42-4233-A5EB-B9B47775E954} = {25FE0F58-B25F-4164-821F-B754C13F0F52}
67-
{85CA75A0-678C-4E80-8B16-943DB0EB5CD4} = {25FE0F58-B25F-4164-821F-B754C13F0F52}
68-
{F39E65D7-EC3D-45FB-BD78-73CE1A984CAC} = {9DB65601-A628-4E1B-A51E-619119068806}
6954
{353987F0-CC4F-4ED9-8803-16E515D49A67} = {9DB65601-A628-4E1B-A51E-619119068806}
55+
{DA56834D-5F42-4DB4-B000-668A757B02F2} = {25FE0F58-B25F-4164-821F-B754C13F0F52}
56+
{01E7AE57-068D-4F5A-B141-4A01CDB74F52} = {25FE0F58-B25F-4164-821F-B754C13F0F52}
7057
EndGlobalSection
7158
EndGlobal

appveyor.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#https://ci.appveyor.com/tools/encrypt
2+
3+
version: '{build}'
4+
skip_tags: true
5+
image: Visual Studio 2017
6+
configuration: Release
7+
install:
8+
- ps: mkdir -Force ".\build\" | Out-Null
9+
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
10+
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
11+
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.1'
12+
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
13+
build_script:
14+
- ps: ./Build.ps1
15+
test: off
16+
artifacts:
17+
- path: artifacts/*.nupkg
18+
deploy:
19+
- provider: NuGet
20+
api_key:
21+
secure: Ls3SZzYU3g7zHCenAUCURHLpfAdZYS3i+YSI6Ot67DX5TkHscUqdEt6O4ZlRsKQp
22+
skip_symbols: true
23+
on:
24+
branch: /^(master|dev)$/

build.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
echo "build: Build started"
2+
3+
Push-Location $PSScriptRoot
4+
5+
if(Test-Path .\artifacts) {
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
8+
}
9+
10+
& dotnet restore --no-cache
11+
12+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
13+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
14+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
15+
16+
echo "build: Version suffix is $suffix"
17+
18+
foreach ($src in ls src/*) {
19+
Push-Location $src
20+
21+
echo "build: Packaging project in $src"
22+
23+
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
24+
if($LASTEXITCODE -ne 0) { exit 1 }
25+
26+
Pop-Location
27+
}
28+
29+
30+
Pop-Location
31+
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# https://github.com/rubicon-oss/LicenseHeaderManager/wiki/Expendable-Properties
2-
extensions: designer.cs generated.cs
3-
extensions: .cs .cpp .h
4-
// ReflectSoftware.Facebook
5-
// Copyright (c) %CurrentYear% ReflectSoftware Inc.
6-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
7-
8-
extensions: .aspx .ascx
9-
<%--
10-
Plato.NET
11-
Copyright (c) %CurrentYear% ReflectSoftware Inc.
12-
Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
13-
--%>
14-
extensions: .xml .config .xsd
15-
<!--
16-
Plato.NET
17-
Copyright (c) %CurrentYear% ReflectSoftware Inc.
18-
Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
1+
# https://github.com/rubicon-oss/LicenseHeaderManager/wiki/Expendable-Properties
2+
extensions: designer.cs generated.cs
3+
extensions: .cs .cpp .h
4+
// ReflectSoftware.Facebook
5+
// Copyright (c) %CurrentYear% ReflectSoftware Inc.
6+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
7+
8+
extensions: .aspx .ascx
9+
<%--
10+
Plato.NET
11+
Copyright (c) %CurrentYear% ReflectSoftware Inc.
12+
Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
13+
--%>
14+
extensions: .xml .config .xsd
15+
<!--
16+
Plato.NET
17+
Copyright (c) %CurrentYear% ReflectSoftware Inc.
18+
Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
1919
-->

samples/WebApiSample.AspNetCore/WebApiSample.AspNetCore.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
<None Update="wwwroot\**\*">
1414
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
1515
</None>
16-
<ProjectReference Include="..\..\src\ReflectSoftware.Facebook.Messenger.Client\ReflectSoftware.Facebook.Messenger.Client.csproj" />
1716
</ItemGroup>
1817

1918
<ItemGroup>
2019
<ProjectReference Include="..\..\src\ReflectSoftware.Facebook.Messenger.AspNetCore.Webhook\ReflectSoftware.Facebook.Messenger.AspNetCore.Webhook.csproj" />
20+
<ProjectReference Include="..\..\src\ReflectSoftware.Facebook.Messenger.Client\ReflectSoftware.Facebook.Messenger.Client.csproj" />
21+
<ProjectReference Include="..\..\src\ReflectSoftware.Facebook.Messenger.Common\ReflectSoftware.Facebook.Messenger.Common.csproj" />
2122
</ItemGroup>
2223

2324
<ItemGroup>

samples/WebApiSample/App_Start/WebApiConfig.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)