users_getLoggedInUser() public method

Returns the user corresponding to the current session object.
public users_getLoggedInUser ( ) : integer
return integer uid
Ejemplo n.º 1
0
 /** 
 	int  fb_sig_user  The uid of the person who is uninstalling your application (e.g. 609143784)  
 	string  fb_sig_session_key  The session_key originally given to your application for the user who is uninstalling the application. This parameter did not appear in the latest requests.  
 	string  fb_sig_api_key  The api_key of your application that is being uninstalled.  
 	int  fb_sig_added  n/a  
 	string  fb_sig  
 */
 private function getContext(FacebookRestClient $client, RingsideSocialSession $network_session)
 {
     $api_key = $client->api_key;
     $session_key = $client->session_key;
     $uid = $client->users_getLoggedInUser();
     $social_session_key = $network_session->getSessionKey();
     $names = $client->users_getInfo($uid, "first_name");
     $name = $names[0];
     $user_name = trim($name['first_name']);
     return "fb_sig_user={$uid}&user_name={$user_name}&fb_sig_api_key={$api_key}&fb_sig_session_key={$session_key}&social_session_key={$social_session_key}";
 }
Ejemplo n.º 2
0
function fbapp_mod_blog_post_publish($blog_id, $id, $title)
{
    global $ssc_site_url, $ssc_database, $ssc_site_path;
    require_once 'facebook.php';
    $api_key = "9c476aaa4b1654c09ede303a7d140a36";
    $secret_key = ssc_var_get('fbapp_blog_secret', '');
    if ($secret_key == '') {
        ssc_add_message(SSC_MSG_CRIT, "Facebook user secret key has not been set up yet!");
        return;
    }
    $session_key = ssc_var_get('fbapp_blog_session', '');
    if ($session_key == '') {
        ssc_add_message(SSC_MSG_CRIT, "Facebook user session key has not been set yet!");
        return;
    }
    $client = new FacebookRestClient($api_key, $secret_key, $session_key);
    if (!$client->users_getLoggedInUser()) {
        ssc_add_message(SSC_MSG_CRIT, "Unable to get userid");
        return;
    }
    $dbres = $ssc_database->query("SELECT body FROM #__blog_post WHERE id = %d LIMIT 1", $id);
    if (!$dbres) {
        ssc_add_message(SSC_MSG_CRIT, "Unable to retrieve posted item from database?!");
        return;
    }
    if (!($data = $ssc_database->fetch_assoc($dbres))) {
        ssc_add_message(SSC_MSG_CRIT, "Unable to retrieve posted item from database?!");
        return;
    }
    $img = null;
    // Extract the first image
    $i = strpos($data['body'], '[[img');
    if ($i !== false) {
        // Some basic error checking for a valid tag
        $j = strpos($data['body'], ']]', $i);
        $k = strpos($data['body'], '[[', $i + 3);
        if ($j !== false && ($j < $k || $k === FALSE)) {
            $path = explode("|", substr($data['body'], $i, $j - $i));
            if (count($path) > 1) {
                $path = $path[1];
                // Now match it up to the right path
                if (strpos($path, "://") === false) {
                    if ($path[0] == "/") {
                        $path = substr($path, 1);
                    }
                    // Relative path
                    if (file_exists($ssc_site_path . "/images/{$path}.jpg") || file_exists($ssc_site_path . "/images/{$path}.png") || file_exists($ssc_site_path . "/images/{$path}")) {
                        // Default to image directory base-dir
                        $img = $ssc_site_url . "/images/{$path}";
                    } elseif (file_exists($ssc_site_path . "/{$path}") || file_exists($ssc_site_path . "/{$path}.jpg") || file_exists($ssc_site_path . "/{$path}.png")) {
                        // Relative to site root instead
                        $img = $ssc_site_url . '/' . $path;
                    }
                }
            }
        }
    }
    // Hackish - TODO later for multiple blog paths, non-root based
    $uri = $ssc_site_url . "/id/{$id}";
    //$result = $client->feed_publishUserAction(30881549425, array("title"=>$title, "uri"=>$uri), '', '', 2);
    $attachment = array('name' => $title, 'href' => $uri, 'caption' => 'A blog post has just been made');
    if ($img != null) {
        $attachment['media'] = array(array('type' => 'image', 'src' => $img, 'href' => $uri));
    }
    $action_links = array(array('text' => 'Read this post', 'href' => $uri));
    $target_id = null;
    //array();
    $uid = null;
    $result = $client->stream_publish(" has been blogging", $attachment, $action_links, $target_id, $uid);
    if ($result) {
        ssc_var_set('fbapp_blog_lastid', $id);
    } else {
        ssc_add_message("Unable to post to FB");
    }
}