function appnet_action($a, $uid, $pid, $action) { require_once 'addon/appnet/AppDotNet.php'; $token = get_pconfig($uid, 'appnet', 'token'); $clientId = get_pconfig($uid, 'appnet', 'clientid'); $clientSecret = get_pconfig($uid, 'appnet', 'clientsecret'); $app = new AppDotNet($clientId, $clientSecret); $app->setAccessToken($token); logger("appnet_action '" . $action . "' ID: " . $pid, LOGGER_DATA); try { switch ($action) { case "delete": $result = $app->deletePost($pid); break; case "like": $result = $app->starPost($pid); break; case "unlike": $result = $app->unstarPost($pid); break; } logger("appnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); } catch (AppDotNetException $e) { logger("appnet_action: Error sending action " . $action . " pid " . $pid . " " . appnet_error($e->getMessage()), LOGGER_DEBUG); } }
print "</blockquote>"; // try fetching the post print "<b>Attempting to fetch sample post from app.net...</b>\n"; print "<blockquote>"; $get = $app->getPost($create['id']); if (!$get || !$get['id'] || $get['id'] != $create['id'] || $get['text'] != $sampleText) { print "Error fetching sample post from ADN:\n"; var_dump($get); exit; } print "Successfully retrieved the sample post from ADN, post ID is " . $get['id'] . "\n"; print "</blockquote>"; // try deleting the post print "<b>Attempting to delete the sample post from app.net...</b>\n"; print "<blockquote>"; $delete = $app->deletePost($create['id']); if (!$delete || !$delete['id'] || $delete['id'] != $create['id']) { print "Error deleting sample post from ADN:\n"; var_dump($delete); exit; } print "Successfully deleted the sample post from ADN, post ID was " . $delete['id'] . "\n"; print "</blockquote>"; // more tests can/should be included here // done tests! print "<b>All test completed successfully!</b>\n"; print "</pre>"; } else { print "<hr />"; print "<h3>Complete user data</h3>"; echo '<pre style="font-weight:bold;font-size:16px">';