/    Sign up×
Community /Pin to ProfileBookmark

Connecting to an API (4 PHP files)

Hello all!

I’m trying to connect my website to one of my supplier’s websites. Basically the way our systems work is that you submit a text request on my site and I have to manually send back the text response to them. My supplier has sent me 4 .php files to connect to his API, but I have no idea how to use it and neither does he.

I have no idea where to start…can anyone help out?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperSep 21.2009 — Please attach files if we're allowed to take a look.

Prior to seeing that, if the API is XML-RPC based (very common web service format which uses HTTP as the transport and XML as the encoding) here is a list of excellent PHP classes for both server and client. Whatever the API being used, documentation as to its use - more specifically the functions and data types involved which define each procedural call - is an absolute must.

-jim
Copy linkTweet thisAlerts:
@JTweedieSep 21.2009 — How can you're supplier not know how to use his own system? Can't he get hold of whoever built it?

If not, the only way you can solve the problem, is a) post the .php file code here for us to see, or b) learn PHP.
Copy linkTweet thisAlerts:
@smohauthorSep 22.2009 — Thank you all for your help so far. Here's a little bit more info.


I have already created a website where people can submit their requests (15 digit text requests).

I would like to know how to implement the following php files into my site so API will work. I have included the 4 ZIP files here so you can see what exactly it is that I'm dealing with. Will I have to copy and paste any kind of copy into my current site? Do I Just upload this somewhere on my site?

For those that are willing to help, I thank you 1 million times in advance. I've zipped the files.

[upl-file uuid=8e5224b2-8b82-4e6e-81ec-1f7ad4e0ef9b size=6kB]help.zip[/upl-file]
Copy linkTweet thisAlerts:
@SrWebDeveloperSep 22.2009 — I looked at the files.

Without documentation, the code reveals the API is indeed XML-RPC (in this case using cURL) and consists of 4 scripts which you would upload into one directory on your server:


[LIST]
  • [*][B]class.APIHttpRequest.php[/B] - the class for the API functions, included by the other 3 scripts

  • [*][B]get.php [/B]- returns IMEI order based on a form where the user supplies a reference ID

  • [*][B]send.php[/B] - sends an IMEI order to the remote server, includes two forms with various fields the user fills out populating fields related to an IMEI order, apparently

  • [*][B]getservices.php[/B] - run this to debug a list of available procedures aka "service list" - used to help you develop your own get/send scripts API calls

  • [/LIST]

    Now it's VERY important you know that in the latter 3 scripts there are 2 configuration variables at the top of each that need to be configured - the user name ($user_name) and API license key ($api_license_key) which allow you to use the remote API. This information comes from the other guy or whomever, and the scripts must be edited with the correct case sensitive information. Luckily, the URI to the API (remote server) is already supplied in the various scripts, but its not enough.

    Obviously an IMEI order and all that is up to you to know - only you can run these scripts and see what happens, lacking documentation (which is pitiful)

    -jim
    Copy linkTweet thisAlerts:
    @smohauthorSep 22.2009 — I looked at the files.

    Without documentation, the code reveals the API is indeed XML-RPC (in this case using cURL) and consists of 4 scripts which you would upload into one directory on your server:


    [LIST]
  • [*][B]class.APIHttpRequest.php[/B] - the class for the API functions, included by the other 3 scripts

  • [*][B]get.php [/B]- returns IMEI order based on a form where the user supplies a reference ID

  • [*][B]send.php[/B] - sends an IMEI order to the remote server, includes two forms with various fields the user fills out populating fields related to an IMEI order, apparently

  • [*][B]getservices.php[/B] - run this to debug a list of available procedures aka "service list" - used to help you develop your own get/send scripts API calls

  • [/LIST]

    Now it's VERY important you know that in the latter 3 scripts there are 2 configuration variables at the top of each that need to be configured - the user name ($user_name) and API license key ($api_license_key) which allow you to use the remote API. This information comes from the other guy or whomever, and the scripts must be edited with the correct case sensitive information. Luckily, the URI to the API (remote server) is already supplied in the various scripts, but its not enough.

    Obviously an IMEI order and all that is up to you to know - only you can run these scripts and see what happens, lacking documentation (which is pitiful)

    -jim[/QUOTE]


    Thanks Jim...

    I've uploaded the files as well as put in the username and API key. However, I don't understand what to do with it now. Also, the Getservices.php is having a php error.

    [code=php]Fatal error: require_once() [function.require]: Failed opening required 'class.XMLHttpRequest.php' (include_path='.:/usr/local/php52/pear') in /home/cellfser/public_html/reseller/api/getservices.php on line 19[/code]

    I'm guessing because this file is missing? I've emailed my supplier about it as well and he said he will get back to me tomorrow.


    Regardless, I'm not sure if this is supposed to be uploaded into it's own directory. I think it would make more sense to copy and paste the code into my main submission page. What do you think?
    Copy linkTweet thisAlerts:
    @SrWebDeveloperSep 23.2009 — To keep things as simple as possible, I already instructed you to put all 4 files in the same directory. In the statement generating that error use this: [COLOR=#000000][COLOR=#dd0000]



    [/COLOR]
    [/COLOR]
    [code=php]require_once ('class.XMLHttpRequest.php'); [/code]

    Full details on "require_once" including links to explaining how paths are used to find files is here.

    Once the errors are resolved and you've added the user name and license key data then [U]run each script manually by direct URL to determine what each is supposed to do[/U]. I took a guess for each based on the code, but I don't know what the heck an "IMEI" order is! As I mentioned, the code apparently presents forms, so fill them out and submit. Looking at the form might help you figure out what each script does/intended use, but if you can't - and no friggin' docs - it's time to contact the other guy as was suggested by others following this thread. Even the debugging script which displays function names and data types doesn't have any meaning unless there is documentation describing [U]usage[/U].

    I will never recommend integrating the scripts into your existing site until all errors are resolved [U]and[/U] you have a solid understanding of what each script does. Otherwise you're introducing complexity and further potential headaches. Cart before the horse.

    This isn't rocket science but API programming is not for newbies either. If you are far beyond your skill level, hire a pro, respectfully.

    -jim
    Copy linkTweet thisAlerts:
    @smohauthorSep 23.2009 — Are there any pros out there that would be willing to do this for me? If so, please PM me your price and timeline!
    Copy linkTweet thisAlerts:
    @smohauthorOct 12.2009 — I have a new supplier with a MUCH better API and with some great documentation. Is there anyone out there that can help me with this? If there are any experts out there that can get this done quick, I'd be willing to pay you as well.

    Please check out the documentation attached below.

    Download Here
    ×

    Success!

    Help @smoh spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.7,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...