Skip to content

Instantly share code, notes, and snippets.

@zeryx
Last active December 16, 2016 17:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeryx/b5eb0c2fb33c75256a326e038bf25952 to your computer and use it in GitHub Desktop.
Save zeryx/b5eb0c2fb33c75256a326e038bf25952 to your computer and use it in GitHub Desktop.
posting a summarizer request with CURL
# A very simple PHP example that sends a HTTP POST to a algorithmia and summarizes text.
#
#available input content types:
# application/json for json
# text/plain for simple string
# application/octet-stream for binary
<?php
$ch = curl_init();
$data ='Your big document of text to get summarized, you could import this as a file as well.';
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://api.algorithmia.com/v1/algo/nlp/Summarizer/0.1.3',
CURLOPT_HTTPHEADER => array('Content-Type:application/text', 'Authorization: Simple <ALGORITHMIA_API_KEY_HERE'),
CURLOPT_POSTFIELDS => $data,
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
)
);
$server_output = curl_exec ($ch);
printf($server_output);
curl_close ($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment