<form method="post"> 
        <h2><?php 
_e('Add Friend Profile', 'hwd');
?>
</h2>
        <?php 
_e('Easily create new profile with API and Fitbit ID', 'hwd');
?>
        

    <?php 
if (isset($_POST['encodedId']) && '' != $_POST['encodedId']) {
    $fitbit_php = new FitBitPHP(HWD_CONSUMER_KEY, HWD_CONSUMER_SECRET, 0, null, 'json');
    $fitbit_php->setOAuthDetails(HWD_FITBIT_TOKEN, HWD_FITBIT_SECRET);
    $fitbit_php->setUser($_POST['encodedId']);
    $profile = $fitbit_php->getProfile();
    // Create post object
    $my_post = array('post_title' => $profile->user->encodedId, 'post_content' => $profile->user->encodedId, 'post_author' => 1, 'post_status' => 'publish', 'post_type' => 'friend');
    // Insert the post into the database
    $post_id = wp_insert_post($my_post, true);
    if (!is_wp_error($post_id)) {
        foreach ($profile->user as $meta_key => $meta_value) {
            add_post_meta($post_id, $meta_key, $meta_value, true);
        }
        ?>
          <div id="message" class="updated">
              <p><strong><?php 
        _e('Friend Added.', 'hwd');
        ?>
</strong></p>
          </div>
Exemple #2
0
        });
    </script>
    <style>
        .bb_container{
            font:14px "ProximaNovaRegular",Arial,Helvetica,sans-serif;
            color: #626161;
            background: #ebebeb url(page_background.jpg) repeat-x;
            margin: 0;
        }
    </style>
</head>
<?php 
//print_r($status);
if ($status == 4) {
    $fitbit->initSession('http://localhost/fitbitsync/index.php');
    $xml = $fitbit->getProfile();
    if ($xml->user->encodedId) {
        ?>
    <body class="bb_container">
        <div style="background-image:url(bbauth.jpg);position: absolute;top:200px;left:35%;height:567px;width:452px;"></div>
        <div style="position: absolute;top:410px;left:35%;height:567px;width:400px;padding:40px;padding-left:80px;">
            <p>Please enter your bodybuilder.com account</p>     
            <div id="bbLoginError" ></div>
            <div class="ui one column stackable center aligned page grid">

                <div class="column">
                <div class="ui form">
                  <div class="field">
                    <label style=""></label>
                    <input type="text" id="bbuser"  name="bbuser" placeholder="Username">
                  </div>