예제 #1
0
<?php

require_once 'AppDotNet.php';
$app = new AppDotNet();
// check that the user is signed in
if ($app->getSession()) {
    // get the current user as JSON
    $data = $app->getUser();
    // accessing the user's cover image
    echo '<body style="background:url(' . $data['cover_image']['url'] . ')">';
    echo '<div style="background:#fff;opacity:0.8;padding:20px;margin:10px;border-radius:15px;">';
    echo '<h1>Welcome to <a target="_blank" href="https://github.com/jdolitsky/AppDotNetPHP">';
    echo 'AppDotNetPHP</a></h1>';
    // accessing the user's name
    echo '<h3>' . $data['name'] . '</h3>';
    // accessing the user's avatar image
    echo '<img style="border:2px solid #000;" src="' . $data['avatar_image']['url'] . '" /><br>';
    // try posting to ADN
    if (isset($_POST['run_tests'])) {
        print "<hr />";
        print "<h3>Testing ADN functionality</h3>";
        print '<pre>';
        print "<b>Attempting to post a test message to app.net...</b>\n";
        print "<blockquote>";
        $sampleText = "Testing posting to app.net using AppDotNetPHP - " . uniqid(mt_rand(0, 100000));
        $create = $app->createPost($sampleText);
        // we should now have a post ID and the text should be the same as above
        if (!$create || !$create['id'] || $create['text'] != $sampleText) {
            print "Error posting sample text to ADN\n";
            var_dump($create);
            exit;