Skip to content

Instantly share code, notes, and snippets.

@Davisy
Last active November 29, 2020 15:38
Show Gist options
  • Save Davisy/faf04a971e5bc3916fd2c8887ea5e20f to your computer and use it in GitHub Desktop.
Save Davisy/faf04a971e5bc3916fd2c8887ea5e20f to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Algorithmia;
class SpamController extends Controller
{
// show form to write the sms message
public function show_form()
{
return view('sms_spam_form');
}
// perform spam detection
public function detect(Request $request){
// valaidate the input
$this->validate($request, [
'message' => 'required|string|min:25',
]);
//collect the message
$message = $request["message"];
// Add client and call the API
$client = Algorithmia::client("YOUR-API-KEY");
$algo = $client->algo("Davis/spam_detection/0.2.0");
// perform prediction and save result
$result = $algo->pipe($message)->result;
return view('sms_spam_result',compact(['message','result']));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment