Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default API GET requests.

    i know this might sound really simple, but what would be the best way to retrieve information by doing a get request in php, like for example the end of the url would be something like
    ?account=joe&pass=xxx&action=showObjectReport

    I'm pretty sure it would be using cURL, not sure how to use that though.
    Cheers for the help, never really used an API before :/
    Joe
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  2. #2
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Joe! View Post
    i know this might sound really simple, but what would be the best way to retrieve information by doing a get request in php, like for example the end of the url would be something like
    ?account=joe&pass=xxx&action=showObjectReport

    I'm pretty sure it would be using cURL, not sure how to use that though.
    Cheers for the help, never really used an API before :/
    Joe
    What on earth are you on about, what API and what are you trying to do?


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  3. #3
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    And why would the pass be in the URL!? That's like giving the key to a prisoner and asking him not to let himself out!

  4. #4
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    Reading that back, it doesn't make sense at all does it. Basically i'm trying to connect to tomtom workfleet to retrieve the location of a vehicle. It uses either HTTP requests like I said about with the url, or SOAP requests which i dont have a clue about.
    I've just seen this on a website, could I use that same technique to retrieve the data?
    PHP Code:
    $url "http://piwik.org/demo/";
    $url .= "?module=API&method=Referers.getKeywords";
    $url .= "&idSite=1&period=month&date=yesterday";
    $url .= "&format=PHP&filter_limit=20";
    $url .= "&token_auth=$token_auth";
    $fetched file_get_contents($url);
    $content unserialize($fetched); 
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  5. #5
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    Also, this is direct from tomtom, but is in ASP, i'm essentially trying to complete the same task in PHP.
    PHP Code:
     url "https://new.webfleet.de/extern?"
      
    url url "lang=" Request.form("lang")
      
    url url "&account=" Request.form("account")
      
    url url "&username=" Request.form("username")
      
    url url "&password=" Request.form("password")
      
    url url "&action=showObjectReportExtern"
      
    Set Req Server.CreateObject("WinHttp.WinHttpRequest.5.1")
      
    Req.Open "GET"url
      Req
    .Send
      Response
    .Write Req.ResponseText
      Set Req 
    nothing 
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Quote Originally Posted by Joe! View Post
    Also, this is direct from tomtom, but is in ASP, i'm essentially trying to complete the same task in PHP.
    PHP Code:
     url "https://new.webfleet.de/extern?"
      
    url url "lang=" Request.form("lang")
      
    url url "&account=" Request.form("account")
      
    url url "&username=" Request.form("username")
      
    url url "&password=" Request.form("password")
      
    url url "&action=showObjectReportExtern"
      
    Set Req Server.CreateObject("WinHttp.WinHttpRequest.5.1")
      
    Req.Open "GET"url
      Req
    .Send
      Response
    .Write Req.ResponseText
      Set Req 
    nothing 
    Something like this should work if you want to use cURL.

    PHP Code:
    <?php

    $parameters    
    = array(

        
    'lang'       => 'Language',
        
    'account'    => 'Account',
        
    'Password'   => 'Password',
        
    'action'     => 'showObjectReportExtern',

    );

    $curl    curl_init();

    curl_setopt$curlCURLOPT_URL'https://new.webfleet.de/extern?' http_build_query$parameters ) );
    curl_setopt$curlCURLOPT_HEADERfalse );
    curl_setopt$curlCURLOPT_RETURNTRANSFERtrue );
    curl_setopt$curlCURLOPT_FOLLOWLOCATIONtrue );
    curl_setopt$curlCURLOPT_SSL_VERIFYPEERfalse );
    curl_setopt$curlCURLOPT_SSL_VERIFYHOSTfalse );

    $response    curl_exec$curl );

    curl_close$curl );

  7. #7
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    Thanks for that Invent!
    Shall test it out when I can
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •