API Integration: PHP

Discussion in 'Web Programming' started by Nick, Apr 14, 2012.

API Integration: PHP
  1. Unread #1 - Apr 14, 2012 at 10:40 PM
  2. Nick
    Joined:
    Feb 12, 2007
    Posts:
    7,204
    Referrals:
    40
    Sythe Gold:
    80

    Nick ♬♩ Young Forever ♪ ♫

    API Integration: PHP

    Can anyone explain the whole concept of how to do API integration on my website of another websites services? I know there are specific input vales necessary, the services API security key, etc but how does that translate to the actual code? Thanks if you're able to help

    Nick
     
  3. Unread #2 - Apr 15, 2012 at 12:40 AM
  4. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    API Integration: PHP

  5. Unread #3 - Apr 15, 2012 at 9:19 AM
  6. Deacon Frost
    Joined:
    Jan 30, 2007
    Posts:
    2,905
    Referrals:
    3
    Sythe Gold:
    57

    Deacon Frost Grand Master
    Banned

    API Integration: PHP

    Lolwut?

    Nick, explain what you mean? The concept is simple...

    Let's take for instance you use Paypal's merchant gateway to accept automated payments. Additionally, you need to store the user's information locally so you can reference it for whatever reason.

    Paypal gives you some different stuff you can use, or you can use a premade 'gateway' script that are available out there. There's some really good ones. During check out, you would send the user to the page with your post data, the post data would be entered to be sent to paypal. When paypal receives the post data, they return to you a confirmation as well as some basic other information. This is all automated, Paypal checks your post data, and then replies with more information.

    You can then save the information in your database for reference.


    APIs are very simple and straight forward. The other side has everything setup, all you have to do is send the right variables and know what variables you're getting back.
     
  7. Unread #4 - Apr 16, 2012 at 10:06 AM
  8. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

    API Integration: PHP

    Surprised SOAP hasn't been mentioned.

    It's commonplace in system to system communication. It allows for remote calling of PHP functions from a PHP script, instead of interpreting HTML results or requiring additional parsing of outputs.

    Recommend reading http://shop.oreilly.com/product/9780596000950.do to learn how to use SOAP properly.

    It's similar to a wget/fopen/cURL request, but with a few more features.
    Code:
    <?php
    $soapClient = new SoapClient( NULL, array( 'location' => "http://yourwebsite.com/api.php", 'uri' => 'http://Otherwebsite.com' ) );
    
    $params = array( 'ID'   => $ID,
                     'Key'  => $Key,
                     'More' => $more
                   );
                   
    $return = $soapClient->__soapCall( 'functionName', $params );
    
    if($return->statusCode() >= 200 && $return->statusCode() < 300 ) {
        // Something good was returned
        print_r($return->results());
    }
    
     
< Need some HTML explaining | Which to learn first? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site