Example #1
0
function instagram_upload()
{
    $content = "<p style='padding:5px'>";
    $content .= "Instagram is a popular photograph apps on iPhone / iPad users<br/>";
    $content .= "Now, without any iOS device you can register an Instagram account or even upload photos to Instagram and share to your timeline :)";
    $content .= "<br/>";
    if (isset($_FILES['foto'])) {
        $instagramapi = new Instagramapi();
        $username = $_POST["username"];
        $password = $_POST["password"];
        $caption = stripslashes(" " . $_POST["caption"]);
        $temp = $_FILES['foto']['tmp_name'];
        $foto = "@" . $temp;
        if ($username && $password && $foto) {
            $res = $instagramapi->login($username, $password);
            if ($res["status"] == "ok") {
                $upl = $instagramapi->upload($foto, $caption);
                if ($upl["status"] == "ok") {
                    $code = $upl["media"]["code"];
                    $instaurl = "http://instagr.am/p/{$code}";
                    $content = trim($upl["media"]["comments"][0]["text"]) . " " . $instaurl;
                    //Send the user's message to twitter
                    $request = API_URL . 'statuses/update.json';
                    $post_data = array('source' => 'dabr', 'status' => $content);
                    $status = twitter_process($request, $post_data);
                    header("Location: " . BASE_URL);
                    exit;
                } else {
                    $msg = "Instagram Error : " . $upl["message"];
                }
            } else {
                $msg = "Instagram Error : " . $res["message"];
            }
        } else {
            $msg = "Please fill username and password";
        }
    } else {
        if ($_POST) {
            $msg = "<b>ERROR :</b> Please select a photo!";
        }
    }
    if (isset($msg)) {
        $_REQUEST["msg"] = $msg;
    }
    if (isset($_REQUEST["msg"])) {
        $content .= "<pre style='padding:5px'><b>ERROR:</b> " . $_REQUEST["msg"] . "</pre><br/>";
    }
    $content .= "<form method='post' enctype='multipart/form-data'>";
    $content .= "<input type='hidden' name='cmd' id='cmd' value='upload'/>";
    $content .= "<p>Use your instagr.am account details to login</p>";
    $content .= '<p>Username:<br /><input type="text" name="username" id="username" /></p>';
    $content .= '<p>Password:<br /><input type="password" name="password" id="password" /></p>';
    $content .= '<p>Select photo to upload:<br/><input type=file name="foto" id="foto"></p>';
    $content .= '<p>Image caption:<br/><textarea type="text" id="caption" name="caption"></textarea></p>';
    $content .= '<p><input type=submit value="Upload!" /></p>';
    $content .= "</form>";
    $content .= "<p><a href='" . BASE_URL . "instagram?cmd=register'>Doesnt have an account? Register Now!</a></p>";
    $content .= "</p>";
    theme('page', 'Instagram', $content);
}
Example #2
0
function user_oauth()
{
    require_once 'OAuth.php';
    // Session used to keep track of secret token during authorisation step
    session_start();
    // Flag forces twitter_process() to use OAuth signing
    $GLOBALS['user']['type'] = 'oauth';
    if ($oauth_token = $_GET['oauth_token']) {
        // Generate ACCESS token request
        $params = array('oauth_verifier' => $_GET['oauth_verifier']);
        $response = twitter_process('https://api.twitter.com/oauth/access_token', $params);
        parse_str($response, $token);
        // Store ACCESS tokens in COOKIE
        $GLOBALS['user']['password'] = $token['oauth_token'] . '|' . $token['oauth_token_secret'];
        // Fetch the user's screen name with a quick API call
        unset($_SESSION['oauth_request_token_secret']);
        $user = twitter_process(API_URL . 'account/verify_credentials.json');
        $GLOBALS['user']['username'] = $user->screen_name;
        _user_save_cookie(1);
        header('Location: ' . BASE_URL);
        exit;
    } else {
        // Generate AUTH token request
        $params = array('oauth_callback' => BASE_URL . 'oauth');
        $response = twitter_process('https://api.twitter.com/oauth/request_token', $params);
        parse_str($response, $token);
        // Save secret token to session to validate the result that comes back from Twitter
        $_SESSION['oauth_request_token_secret'] = $token['oauth_token_secret'];
        // redirect user to authorisation URL
        $authorise_url = 'https://api.twitter.com/oauth/authorize?oauth_token=' . $token['oauth_token'];
        header("Location: {$authorise_url}");
    }
}
Example #3
0
function twitter_lists_tweets($user, $list)
{
    // Tweets belonging to a list
    $url = API_URL . "lists/statuses.json?slug={$list}&owner_screen_name={$user}&include_entities=true";
    $page = intval($_GET['page']);
    if ($page > 0) {
        $url .= '&page=' . $page;
    }
    return twitter_process($url);
}
Example #4
0
function twitter_lists_tweets($user, $list)
{
    // Tweets belonging to a list
    $url = API_URL . "{$user}/lists/{$list}/statuses.json";
    $page = intval($_GET['page']);
    if ($page > 0) {
        $url .= '?page=' . $page;
    }
    return twitter_process($url);
}
Example #5
0
File: user.php Project: xctcc/npt
function user_itap()
{
    require_once 'OAuth.php';
    session_start();
    $GLOBALS['user']['type'] = 'oauth';
    $params = array('oauth_callback' => BASE_URL . 'oauth');
    $response = twitter_process('https://api.twitter.com/oauth/request_token', $params);
    parse_str($response, $token);
    $_SESSION['oauth_request_token_secret'] = $token['oauth_token_secret'];
    $authorise_url = BASE_URL . 'oauthproxy/authorize?oauth_token=' . $token['oauth_token'];
    header("Location: {$authorise_url}");
}
Example #6
0
function twitter_lists_tweets($user, $list)
{
    // Tweets belonging to a list
    $count = setting_fetch('ltpp', 20);
    // https://dev.twitter.com/docs/api/1/get/lists/statuses
    // How many tweets to show
    $perPage = setting_fetch('perPage', 20);
    $url = API_URL . "lists/statuses.json?slug={$list}&owner_screen_name={$user}&per_page={$perPage}&include_entities=true&include_rts=true";
    $page = intval($_GET['page']);
    if ($page > 0) {
        $url .= '&page=' . $page;
    }
    $url .= '&per_page=' . $count;
    return twitter_process($url);
}
Example #7
0
function twitter_user_info($username = null)
{
    if (!$username) {
        $username = user_current_username();
    }
    $request = API_URL . "users/show.json?screen_name={$username}&include_entities=true";
    $user = twitter_process($request);
    return $user;
}
Example #8
0
function twitter_lists_user_lists($user)
{
    // Lists a user has created
    return twitter_process(API_NEW . "lists/list.json?screen_name={$user}");
}
Example #9
0
File: lists.php Project: xctcc/npt
function lists_list_edit_page($user, $list)
{
    if ($_POST['name']) {
        $post_data = array('owner_screen_name' => $user, 'slug' => $list, 'name' => stripslashes($_POST['name']), 'mode' => $_POST['mode'], 'description' => $_POST['description']);
        $p = twitter_process(API_ROOT . "lists/update.json", $post_data);
        twitter_refresh("lists/{$user}/{$p->slug}");
    }
    $p = twitter_process(API_ROOT . "lists/show.json?owner_screen_name={$user}&slug={$list}");
    $content = "<form method=\"post\" action=\"" . BASE_URL . "lists/{$user}/{$list}/edit\" enctype=\"multipart/form-data\">" . __("List Name") . ": <input type=\"text\" name=\"name\" value=\"{$p->name}\" /> (Max 20) <br />" . __("Privacy") . ": <select name=\"mode\">";
    $current_mode = $p->mode === "public";
    $content .= "<option value=\"public\"" . ($current_mode ? " selected=\"selected\"" : "") . ">" . __("Public") . "</option>";
    $content .= "<option value=\"private\"" . ($current_mode ? "" : " selected=\"selected\"") . ">" . __("Private") . "</option>";
    $content .= "</select><br />" . __("Description") . ": (Max 160) <br /><textarea name=\"description\" style=\"width:95%\" rows=\"3\" id=\"description\" >{$p->description}</textarea><br /><input type=\"submit\" value=\"" . __("Update") . "\" /></form>";
    return theme('page', __("Edit List Details"), $content);
}
Example #10
0
function twitter_user_info($username = null)
{
    if (!$username) {
        $username = user_current_username();
    }
    $request = API_NEW . "users/show.json?screen_name={$username}";
    $user = twitter_process($request);
    return $user;
}