1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

Help with simple API code.

Discussion in 'General Scripting Chat' started by koulde, Sep 11, 2018.

  1. koulde

    koulde Newbie

    Joined:
    Aug 3, 2013
    Messages:
    40
    Likes Received:
    32
    Gender:
    Male
    Occupation:
    DbD/AbN
    Location:
    Tylos
    Home Page:
    Hello,
    I must say from the begging that I am not familiar with any of the programming languages, I barely know some PHP and thats just to fix wordpress bugs.

    I've got this API for SMS portal. I am suppose to send bulk sms to clients each with a specific text, and since I lack the experience I've been using excel and google docs with both mobile numbers and messages in certain cells to open the urls and execute the "send message" command ( I think its called "call" or something) and the sms portal server is suppose to return a code if the SMS was sent or not. Well, it hits and miss since importdata function isn't that much.

    This is API when used as a url:
    https://www.[the website].com/api/?username=[the username]&password=[the api password]&sms=[the message]&mobile=[the mobile phone]&binary=[sms language]

    If its successful in sending the message it will return a code on screen as such:
    OK_1_1

    Viewing the screen as "view-source" shows the following:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    OK_1_1

    I am totally lost, wish I knew some vb to get this done.
    I am hoping if anyone can guide me to execute 200 urls and return the code I get as result.
     
  2. SpoonFeeder

    SpoonFeeder Jr. VIP Jr. VIP

    Joined:
    Mar 19, 2017
    Messages:
    1,606
    Likes Received:
    1,969
    Gender:
    Male
    Occupation:
    SpoonFeeding & Babysitting the Noobs.
    Location:
    Click the link below if you're new to BHW!
    Home Page:
    Your question is missing the most important piece of information., which is your current working code.

    What you need right now is to put your code that calls the API into a loop. For ex,

    Code:
    Dim i As Integer
    i = 1
    
    Do While i < 200
        // insert your api call request 
        // fetch the result and save the response into a column
        i = i + 1
    Loop
     
  3. koulde

    koulde Newbie

    Joined:
    Aug 3, 2013
    Messages:
    40
    Likes Received:
    32
    Gender:
    Male
    Occupation:
    DbD/AbN
    Location:
    Tylos
    Home Page:
    I did not build any code, nothing. I don't know how. All I am doing now is this and repeat for the whole list:
    =importdata(CONCATENATE("https://www.website.com/api/?username=",Settings!B$1,"&password=",Settings!B$2,"&sms=",C2,"&mobile=",B2,"&binary=0"))

    Sorry if my thread isn't clear enough.
     
  4. Sebastian Rooks

    Sebastian Rooks Registered Member

    Joined:
    Nov 16, 2015
    Messages:
    95
    Likes Received:
    64
    Location:
    Middle America
    #!/usr/bin/python3
    import requests

    username = 'username'
    pasword = 'password'
    message = 'message'

    url = 'https://www.THEWEBSITE.com/api/?username={username)&password={password}&sms={message}&mobile={phone}&binary={lang}'.format(
    username=username, password=password, message=message)

    r = requests.get(url, timeout=30)

    json = r.json()



    It isn't much, but it's a nudge in the right direction.