Skip to content

Instantly share code, notes, and snippets.

@codenoid
Last active December 25, 2023 09:09
Show Gist options
  • Save codenoid/3edc9c048206cf7fb2ce90216e3e025a to your computer and use it in GitHub Desktop.
Save codenoid/3edc9c048206cf7fb2ce90216e3e025a to your computer and use it in GitHub Desktop.

Revisions

  1. codenoid revised this gist Dec 19, 2019. No changes.
  2. codenoid revised this gist Dec 19, 2019. 2 changed files with 46 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions node.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    var request = require('request');

    var headers = {
    'User-Agent': 'Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0',
    'Accept': '*/*',
    'Accept-Language': 'en-US,en;q=0.5',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'X-Requested-With': 'XMLHttpRequest',
    'Origin': 'https://s.id',
    'Connection': 'keep-alive',
    'Referer': 'https://s.id/'
    };

    var dataString = 'url=https%3A%2F%2Fne.com';

    var options = {
    url: 'https://s.id/api/public/link/shorten',
    method: 'POST',
    headers: headers,
    body: dataString
    };

    function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
    console.log(body);
    }
    }

    request(options, callback);
    17 changes: 17 additions & 0 deletions php.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <?php
    include('vendor/rmccue/requests/library/Requests.php');
    Requests::register_autoloader();
    $headers = array(
    'User-Agent' => 'Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0',
    'Accept' => '*/*',
    'Accept-Language' => 'en-US,en;q=0.5',
    'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
    'X-Requested-With' => 'XMLHttpRequest',
    'Origin' => 'https://s.id',
    'Connection' => 'keep-alive',
    'Referer' => 'https://s.id/'
    );
    $data = array(
    'url' => 'https://ne.com'
    );
    $response = Requests::post('https://s.id/api/public/link/shorten', $headers, $data);
  3. codenoid revised this gist Dec 19, 2019. 3 changed files with 3 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion dart.dart
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ void main() async {
    'Accept-Encoding': 'gzip',
    };

    var data = 'url=https%3A%2F%2Fne.coma';
    var data = 'url=https%3A%2F%2Fne.com';

    var res = await http.post('https://s.id/api/public/link/shorten', headers: headers, body: data);
    if (res.statusCode != 200) throw Exception('post error: statusCode= ${res.statusCode}');
    2 changes: 1 addition & 1 deletion golang.go
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ import (

    func main() {
    client := &http.Client{}
    var data = []byte(`{url=https%3A%2F%2Fne.coma}`)
    var data = []byte(`{url=https%3A%2F%2Fne.com}`)
    req, err := http.NewRequest("POST", "https://s.id/api/public/link/shorten", data)
    if err != nil {
    log.Fatal(err)
    2 changes: 1 addition & 1 deletion rust.rs
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ fn main() -> Result<(), reqwest::Error> {
    let res = reqwest::Client::new()
    .post("https://s.id/api/public/link/shorten")
    .headers(headers)
    .body("url=https%3A%2F%2Fne.coma")
    .body("url=https%3A%2F%2Fne.com")
    .send()?
    .text()?;
    println!("{}", res);
  4. codenoid created this gist Dec 19, 2019.
    1 change: 1 addition & 0 deletions curl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    curl 'https://s.id/api/public/link/shorten' -H 'User-Agent: Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: https://s.id' -H 'Connection: keep-alive' -H 'Referer: https://s.id/' --data 'url=https%3A%2F%2Fne.com'
    21 changes: 21 additions & 0 deletions dart.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import 'package:http/http.dart' as http;

    void main() async {
    var headers = {
    'User-Agent': 'Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0',
    'Accept': '*/*',
    'Accept-Language': 'en-US,en;q=0.5',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'X-Requested-With': 'XMLHttpRequest',
    'Origin': 'https://s.id',
    'Connection': 'keep-alive',
    'Referer': 'https://s.id/',
    'Accept-Encoding': 'gzip',
    };

    var data = 'url=https%3A%2F%2Fne.coma';

    var res = await http.post('https://s.id/api/public/link/shorten', headers: headers, body: data);
    if (res.statusCode != 200) throw Exception('post error: statusCode= ${res.statusCode}');
    print(res.body);
    }
    34 changes: 34 additions & 0 deletions golang.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    package main

    import (
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
    )

    func main() {
    client := &http.Client{}
    var data = []byte(`{url=https%3A%2F%2Fne.coma}`)
    req, err := http.NewRequest("POST", "https://s.id/api/public/link/shorten", data)
    if err != nil {
    log.Fatal(err)
    }
    req.Header.Set("User-Agent", "Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0")
    req.Header.Set("Accept", "*/*")
    req.Header.Set("Accept-Language", "en-US,en;q=0.5")
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
    req.Header.Set("X-Requested-With", "XMLHttpRequest")
    req.Header.Set("Origin", "https://s.id")
    req.Header.Set("Connection", "keep-alive")
    req.Header.Set("Referer", "https://s.id/")
    resp, err := client.Do(req)
    if err != nil {
    log.Fatal(err)
    }
    bodyText, err := ioutil.ReadAll(resp.Body)
    if err != nil {
    log.Fatal(err)
    }
    fmt.Printf("%s\n", bodyText)
    }
    18 changes: 18 additions & 0 deletions python.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import requests

    headers = {
    'User-Agent': 'Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0',
    'Accept': '*/*',
    'Accept-Language': 'en-US,en;q=0.5',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'X-Requested-With': 'XMLHttpRequest',
    'Origin': 'https://s.id',
    'Connection': 'keep-alive',
    'Referer': 'https://s.id/',
    }

    data = {
    'url': 'https://ne.com'
    }

    response = requests.post('https://s.id/api/public/link/shorten', headers=headers, data=data)
    24 changes: 24 additions & 0 deletions rust.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    extern crate reqwest;
    use reqwest::headers::*;

    fn main() -> Result<(), reqwest::Error> {
    let mut headers = HeaderMap::new();
    headers.insert(USER_AGENT, "Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0".parse().unwrap());
    headers.insert(ACCEPT, "*/*".parse().unwrap());
    headers.insert(ACCEPT_LANGUAGE, "en-US,en;q=0.5".parse().unwrap());
    headers.insert(CONTENT_TYPE, "application/x-www-form-urlencoded; charset=UTF-8".parse().unwrap());
    headers.insert(X_REQUESTED_WITH, "XMLHttpRequest".parse().unwrap());
    headers.insert(ORIGIN, "https://s.id".parse().unwrap());
    headers.insert(CONNECTION, "keep-alive".parse().unwrap());
    headers.insert(REFERER, "https://s.id/".parse().unwrap());

    let res = reqwest::Client::new()
    .post("https://s.id/api/public/link/shorten")
    .headers(headers)
    .body("url=https%3A%2F%2Fne.coma")
    .send()?
    .text()?;
    println!("{}", res);

    Ok(())
    }