Rithvik Vibhu
Rithvik Vibhu

Reputation: 441

Where to make a POST to for crumbs url shortening service Advanced API

I have a PHP/JavaScript site (offline). I am using http://crum.bs/ for shortening URLs.

Here, there are 2 types of APIs provided by crum.bs:

  1. Simple Shorten, and
  2. Advanced Shorten

I am currently using the simple shorten API. The base URL to make a GET request is http://crum.bs/api.php?function=simpleshorten&url=[insert url here].

Now, I am planning to change it to the advanced API which requires POST.

I can't find the Base for this anywhere on that page (Or in Google). The API Reference Page is http://blog.crum.bs/?p=12. Does anybody know what it is?

Upvotes: 0

Views: 216

Answers (1)

fullybaked
fullybaked

Reputation: 4127

From what I see you would submit your POST request to the same path

http://crum.bs/api.php

You just need to pass the variables in the request (which technically would look the same as the Simple version, just a different HTTP verb is used)

$ch = curl_init();
$curlConfig = array(
    CURLOPT_URL            => "http://crum.bs/api.php",
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => array(
        'url' => 'http://www.some-really-long-url.com/with/a/lot/of/text/etc.html',
        'desc' => 'some other data',
    ),
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);

The $result var will contain the JSON response from crum.bs service

Upvotes: 1

Related Questions