Adsense

  • Latest News

    Monday, 6 June 2016

    API/JSON Parsing of v-commission using php and mysql


    Coupon Site Developers may find this useful, if using WordPress popular templates: CouponXL, Couponer etc.

    vCommission is India's Leading Affiliate Network which provides API's & documentation to export coupons in json, xls, csv etc formats.
    After, a lot of searching I found one paid plugin to import coupons to WordPress templates but I have free working trick to generate real-time coupons to your WordPress sites.

    1. Create php script to get coupons from API & store in your database: Source Code

    <?php

            // database connection details
            $MySQL_host     = 'localhost';
            $MySQL_username = ' ';
            $MySQL_password = ' ';
            $MySQL_database = ' ';

            // if could not connect to database
            if (!($connection = @mysql_connect($MySQL_host, $MySQL_username, $MySQL_password)))

                // stop execution and display error message
                die('Error connecting to the database!<br>Make sure you have specified correct values for host, username and password.');

            // if database could not be selected
            if (!@mysql_select_db($MySQL_database, $connection))

                // stop execution and display error message
                die('Error selecting database!<br>Make sure you have specified an existing and accessible database.');

    $url = 'https://tools.vcommission.com/api/coupons.php?apikey=YOURAPIKEY';
    $content = file_get_contents($url);
    $json = json_decode($content, true);

    foreach($json as $item) {
     //store all $item into your DB
    }

    ?>

    2. Create php script displaying coupons using Pagination: Zebra_Pagination

        display your stored coupons using this script

    3. Embed url using <iframe src="http://www.yoursite.com/phpscript.php" /> into your WordPress page.

    Comment/Email if source code required!
    email@vslcreations.in

    • Blogger Comments
    • Facebook Comments

    2 comments:

    Post a Comment

    Item Reviewed: API/JSON Parsing of v-commission using php and mysql Rating: 5 Reviewed By: Vishal Aditya
    Scroll to Top