function infusionWholesaler_settings_page()
{
    // if they shouldnt be here, make them leave
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
    }
    ?>
    <div>
    <?php 
    screen_icon();
    ?>
    <h2>IS to WP Form Settings</h2>

    <?php 
    global $infusionsoft;
    retrieve_token();
    global $newToken;
    if ($newToken) {
        echo '<p>You are authenticated.</p>';
    } else {
        echo '<a href="' . $infusionsoft->getAuthorizationUrl() . '">Click here to authorize</a>';
    }
    // end oAuth IS STUFF
    ?>
    </div>
  <?php 
}
Exemple #2
0
<?php

/** This is the callback, what we do is take 'oauth_verifier' from our $_REQUEST, and pass this back
 *  to trademe who will give us another token, an access token, which we can use to make actual useful
 *  requests in future.
 */
require_once 'include/init.php';
// We must use the same request token we obtained in connect.php
$RequestToken = retrieve_token('request');
trademe()->set_token($RequestToken);
// And now we get the access token using the verifier
$AccessToken = trademe()->get_access_token($_REQUEST['oauth_verifier']);
// Which we save, because we now can use this to make any future requests
//  until the access token expires, which I believe for TradeMe is a year (?)
store_token($AccessToken);
include '_header.php';
?>

      <h1 class="css-content-legend">We are (in theory) connected To TradeMe</h1>      
         
      <p>
        You don't have to reauthorise unless you lose the Access Token or it expires. So store the Access Token in a database, config file, or whatever so your users don't have to reauthorise all the time.  
      </p>     
      
      <p>This example only stores it in the $_SESSION, that's probably not very useful to you in production but it suffices for the examples :-)</p>
      
      <p>
        Now you can <a href="index.php">try it out with some simple demos</a>.
      </p>
      
    
Exemple #3
0
<?php

/** This is an example of using the Access Token to save a note to the user's watchlist.
 */
require_once 'include/init.php';
// We set the access token which we stored in callback.php (at some earlier time)
$AccessToken = retrieve_token('access');
trademe()->set_token($AccessToken);
include '_header.php';
if (isset($_REQUEST['Delete'])) {
    $Response = trademe()->delete('MyTradeMe/Notes/' . $_REQUEST['Delete']['ListingId'] . '/' . $_REQUEST['Delete']['NoteId'] . '/0');
}
if (isset($_REQUEST['Note'])) {
    // And then simply call the "endpoint" at trademe.
    // $Response = trademe()->SaveNote($_REQUEST['Note']['ListingID'], $_REQUEST['Note']['Note']);
    $Response = trademe()->post('MyTradeMe/Notes::SaveNoteRequest', array('Text' => $_REQUEST['Note']['Note'], 'ListingId' => $_REQUEST['Note']['ListingID']));
    // We can check the response is OK
    if ($Response->is_ok()) {
        echo "<h1>Success</h1>";
        echo "<p>TradeMe returned the following XML.</p>";
        echo "<pre>" . htmlspecialchars($Response->asIndentedXML()) . "</pre>";
        echo "<p>You will see it includes a &quot;NoteId&quot;, perhaps you want to use that your application, this is how you would get it.</p>";
        echo "<pre>" . htmlspecialchars('$TheNoteId = (int) $Response->NoteId;') . "</pre>";
        echo "<p>The cast is because we are talking to an SimpleXMLElement there, to be safe, always cast to what you want (or at least expect).</p>";
    } else {
        // If an error did happen (is_ok() is false) then error_message() will give
        // you the error message in the trademe response, or something like that.
        echo "<h1>Failure</h1>";
        echo "<p>Error response from TradeMe follows...</p>";
        echo "<pre>" . htmlspecialchars($Response->error_message()) . "</pre>";
        // echo $Response->error_message();
function grab_form_html_callback()
{
    global $wpdb;
    // this is how you get access to the database
    global $infusionsoft;
    global $unserializedIsToken;
    // make sure the token is good or refresh it if not
    retrieve_token();
    // set the token with the unserialized token object
    $infusionsoft->setToken($unserializedIsToken);
    // ID of requested form
    $desiredFormID = intval($_POST['formID']);
    // call up that HTML
    $desiredFormHTML = $infusionsoft->webForms()->getHTML($desiredFormID);
    // find just the form, because Infusinsoft returns some silly stuff
    $regex = '/<form (.*?)>(.*?)<\\/form>/is';
    preg_match_all($regex, $desiredFormHTML, $match);
    // set the plain ol chosen form as a var
    $plainChosenForm = $match[0][0];
    echo $plainChosenForm;
    wp_die();
    // this is required to terminate immediately and return a proper response
}