当前位置: 首页>>代码示例>>PHP>>正文


PHP Facebook::set_user方法代码示例

本文整理汇总了PHP中Facebook::set_user方法的典型用法代码示例。如果您正苦于以下问题:PHP Facebook::set_user方法的具体用法?PHP Facebook::set_user怎么用?PHP Facebook::set_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook的用法示例。


在下文中一共展示了Facebook::set_user方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $facebook = new Facebook(OpfApplicationConfig::SITE_API_KEY, OpfApplicationConfig::SITE_API_SECRET);
     $this->facebook = $facebook;
     $facebook->require_frame();
     $this->userId = $facebook->require_login();
     try {
         $this->addUrl = $facebook->get_add_url();
         $this->isAppAdded = $facebook->api_client->users_isAppAdded();
     } catch (Exception $e) {
         $facebook->set_user(null, null);
         $facebook->redirect(OpfApplicationConfig::APP_CALLBACK_URL);
     }
 }
开发者ID:TheProjecter,项目名称:openface,代码行数:14,代码来源:OpfSiteWrapper.php

示例2: fGetFacebookPhotos

function fGetFacebookPhotos($strCount)
{
    $api_key = 'e59c32974d9a3136017900df131704c7';
    $secret = '8d6e4b2d26b7283c473cd23d635220df';
    //$key = 'ba3db7c97a3da15350d77484-45500018';
    $key = 'acaa9e7ae3c4e3ea99f107d2-45500018';
    $ashley = '45500234';
    $bobby = '45500018';
    $strReturn = '';
    $intCounter = 0;
    $facebook = new Facebook($api_key, $secret);
    $facebook->set_user($bobby, $key);
    $arrAshley = $facebook->api_client->photos_get($ashley, '', '');
    $arrBobby = $facebook->api_client->photos_get($bobby, '', '');
    for ($intI = 0; $intCounter < $strCount; $intI++) {
        // Ashley or Bobby
        if ($intCounter % 2 == 1) {
            $arrCurrent = $arrAshley;
        } else {
            $arrCurrent = $arrBobby;
        }
        // Read Values From Current Array
        $strImage = $arrCurrent[$intI]['src'];
        $strLink = $arrCurrent[$intI]['link'];
        $strCaption = $arrCurrent[$intI]['caption'];
        $strAid = $arrCurrent[$intI]['aid'];
        $strPid = $arrCurrent[$intI]['pid'];
        // Remove Duplicates
        if (!stristr($strReturn, $strImage)) {
            // Update Counter
            $intCounter++;
            // Determine Caption
            if ($strCaption == "") {
                $strCaption = "Recent Facebook Photo " . $intCounter;
            }
            // Cached Image
            $strCache = 'cache/' . $strAid . '-' . $strPid . '.jpg';
            // Read From Cache Or Thumb
            if (!file_exists($strCache)) {
                $strUrl = '/status/facebook_thumb.php?aid=' . $strAid . '&pid=' . $strPid . '&i=' . $strImage;
            } else {
                $strUrl = '/status/' . $strCache;
            }
            // Add Image
            $strReturn .= '<a href="' . $strLink . '" target="_blank" title="' . $strCaption . '"><img src="' . $strUrl . '" alt="' . $strCaption . '" /></a>';
        }
    }
    return $strReturn;
}
开发者ID:bobbyearl,项目名称:bobbyearl.github.io,代码行数:49,代码来源:facebook.php

示例3: catch

    //public canvas page
    $user = $facebook->get_loggedin_user();
} else {
    //do a login and configuration or show them the app if they have already installed it
    $user = $facebook->require_login();
    $appcallbackurl = 'http://www.wordans.com/wordans_flash/facebook_callback';
    // catch the exception that gets thrown if the cookie has
    // an invalid session_key in it
    try {
        if (!$facebook->api_client->users_isAppAdded()) {
            $facebook->redirect($facebook->get_add_url());
        }
    } catch (Exception $ex) {
        // this will clear cookies for your application and
        // redirect them to a login prompt
        $facebook->set_user(null, null);
        $facebook->redirect($appcallbackurl);
    }
}
?>
<!--<fb:swf swfsrc='http://www.wordans.com.com/flash/facebook/loader.swf?version="1" ' imgsrc='http://www.skeeker.com/sites/facebook/wordans/clickhere.jpg' width='185' height='280' flashvars='asset_path=http://www.skeeker.com/sites/facebook/wordans/' />-->



<script type="text/javascript" src="swfobject.js"></script>
<style type="text/css">
	
	body { 
		background-color: #ffffff;
		font: .8em/1.3em verdana,arial,helvetica,sans-serif;
	}
开发者ID:ersandeepdh,项目名称:izishirt,代码行数:31,代码来源:index.php

示例4: array

$_COOKIE = array();
$secret = FB_API_SECRET;
$facebook = new Facebook(FB_API_KEY, FB_API_SECRET);
$user = $facebook->get_loggedin_user();
if (!$user) {
    $user = $_REQUEST['uid'];
    if (!$user) {
        $facebook->redirect($facebook->get_login_url(FB_APP_URL, 1));
    }
    $key = $_REQUEST['key'];
    $token = $_REQUEST['token'];
    $check = md5($user . $secret);
    if ($check != $token) {
        die("Invalid Signature");
    }
    $facebook->set_user($user, $key);
}
$key = $facebook->api_client->session_key;
$token = md5($user . $secret);
// This is used to append to internal links
$params = "uid={$user}&key={$key}&token={$token}";
?>
    <div class="fbgreybox" style="width: 500px;">Welcome to FriendExport.</div>
    <br><br>
    <div class="fbbody">
      <p>This application lets you download your friend list. That is all.</p>
      <p>It doesn't do ads, invites or anything annoying.</p>
      <p>CSV is a type of spreadsheet. You can open it using Excel or a similar spreadsheet program.</p>
      <p>Please note that it is not possible to obtain a friend&#39;s email address this way, facebook doesn't allow it.</p>
    </div>
    <br><br>
开发者ID:sproates,项目名称:friendexport,代码行数:31,代码来源:index.php

示例5: facebook

 static function facebook($key)
 {
     if (!isset($key)) {
         if (isset(self::$facebook)) {
             return self::$facebook;
         }
     }
     if (isset(self::$facebooks[$key])) {
         return self::$facebooks[$key];
     }
     $fb_prefix = 'fb_sig_';
     // Get the facebook object from POST, if any
     if (isset($_POST[$fb_prefix . 'app_id'])) {
         $app_id = $_POST[$fb_prefix . 'app_id'];
         $fb_apps = Pie_Config::get('users', 'facebookApps', array());
         $fb_info = null;
         $fb_key = null;
         foreach ($fb_apps as $key => $a) {
             if (isset($a['appId']) and $a['appId'] == $app_id) {
                 $fb_info = $a;
                 $fb_key = $key;
                 break;
             }
         }
         if (isset($fb_info['apiKey']) && isset($fb_info['secret'])) {
             $facebook = new Facebook($fb_info['apiKey'], $fb_info['secret']);
             Users::$facebook = $facebook;
             Users::$facebooks[$app_id] = $facebook;
             Users::$facebooks[$key] = $facebook;
             return $facebook;
         }
     }
     $fb_info = Pie_Config::get('users', 'facebookApps', $key, array());
     if ($fb_info) {
         if (isset($_COOKIE[$fb_info['apiKey'] . '_user']) and isset($_COOKIE[$fb_info['apiKey'] . '_session_key'])) {
             $facebook = new Facebook($fb_info['apiKey'], $fb_info['secret']);
             $facebook->set_user($_COOKIE[$fb_info['apiKey'] . '_user'], $_COOKIE[$fb_info['apiKey'] . '_session_key']);
             Users::$facebooks[$fb_info['appId']] = $facebook;
             Users::$facebooks[$key] = $facebook;
         }
         return $facebook;
     }
     // Otherwise, this facebook object isn't there
     return null;
 }
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:45,代码来源:Users.php

示例6: fopen

require_once 'layouts/layout_functions.php5';
include 'layouts/profile_layouts/normal.php5';
include 'layouts/profile_layouts/block.php5';
// create a log file
$myFile = "cronjob.log";
$fh = fopen($myFile, 'w');
$facebook = new Facebook($appapikey, $appsecret);
$facebook->api_client->session_key = $infinite_session_key;
// create a db conectoin
$database_connection = new database();
$all_users = $database_connection->get_all_users();
$profile_fbml = "";
$num_rows = mysql_num_rows($all_users);
$count = 0;
// set that user
$facebook->set_user('741028155', $infinite_session_key);
while ($row = mysql_fetch_row($all_users)) {
    $fb_id = $row[0];
    $zooomr_id = $row[1];
    $layout_id = $row[2];
    fwrite($fh, "Updating user: " . $fb_id . " with zooomr ID " . $zooomr_id . " using layout " . $layout_id . "\n");
    $rss = @fetch_rss("http://www.zooomr.com/services/feeds/public_photos/?id={$zooomr_id}&format=rss_200");
    fwrite($fh, "Got RSS\n");
    if (0 != count($rss->items)) {
        $image_array = array();
        fwrite($fh, "Creating image set\n");
        foreach ($rss->items as $item) {
            // create an image
            $image = new zooomr_image($item['description'] . "<br />" . $item['title']);
            array_push($image_array, $image);
            fwrite($fh, "Created an image...\n");
开发者ID:BGCX067,项目名称:facebook-zooomr-rss-reader-svn-to-git,代码行数:31,代码来源:cronjob.php5

示例7: sfc_publish_automatic

function sfc_publish_automatic($id, $post)
{
    // check to make sure post is published
    if ($post->post_status !== 'publish') {
        return;
    }
    // check options to see if we need to send to FB at all
    $options = get_option('sfc_options');
    if (!$options['autopublish_app'] && !$options['autopublish_profile']) {
        return;
    }
    // load facebook platform
    include_once 'facebook-platform/facebook.php';
    $fb = new Facebook($options['api_key'], $options['app_secret']);
    // to do this autopublish, we might need to switch users
    if ($options['user'] && $options['session_key']) {
        $tempuser = $fb->user;
        $tempkey = $fb->api_client->session_key = $session_key;
        $fb->set_user($options['user'], $options['session_key']);
    } else {
        return;
        // safety net: if we don't have a user and session key, we can't publish properly.
    }
    // build the post to send to FB
    // apply the content filters, in case some plugin is doing weird image stuff
    $content = apply_filters('the_content', $post->post_content);
    // look for the images to add with image_src
    $images = array();
    // get the post thumbnail, put it first in the image list
    if (current_theme_supports('post-thumbnails')) {
        if (has_post_thumbnail($post->ID)) {
            $thumbid = get_post_thumbnail_id($post->ID);
            $att = wp_get_attachment_image_src($thumbid, 'full');
            $images[] = $att[0];
        }
    }
    // look for any images in the content
    if (preg_match_all('/<img (.+?)>/', $content, $matches)) {
        foreach ($matches[1] as $match) {
            foreach (wp_kses_hair($match, array('http')) as $attr) {
                $img[$attr['name']] = $attr['value'];
            }
            if (isset($img['src'])) {
                if (isset($img['class']) && false === strpos($img['class'], 'wp-smiley')) {
                    // ignore smilies
                    $images[] = $img['src'];
                }
            }
        }
    }
    // build the attachment
    $permalink = get_permalink($post->ID);
    $attachment['name'] = $post->post_title;
    $attachment['href'] = $permalink;
    $attachment['description'] = sfc_publish_make_excerpt($post->post_content);
    $attachment['comments_xid'] = urlencode($permalink);
    // image attachments (up to 5, as that's all FB allows)
    $count = 0;
    foreach ($images as $image) {
        $attachment['media'][$count]['type'] = 'image';
        $attachment['media'][$count]['src'] = $image;
        $attachment['media'][$count]['href'] = $permalink;
        $count++;
        if ($count == 5) {
            break;
        }
    }
    // Read Post link
    $action_links[0]['text'] = 'Read Post';
    $action_links[0]['href'] = $permalink;
    // Link to comments
    $action_links[1]['text'] = 'See Comments';
    $action_links[1]['href'] = get_comments_link($post->ID);
    // publish to page
    if ($options['autopublish_app'] && !get_post_meta($id, '_fb_post_id_app', true) && $options['fanpage']) {
        if ($options['fanpage']) {
            $who = $options['fanpage'];
        } else {
            $who = $options['appid'];
        }
        // check to see if we can send to FB at all
        $result = $fb->api_client->users_hasAppPermission('publish_stream', $who);
        if (!$result) {
            break;
        }
        $fb_post_id = $fb->api_client->stream_publish(null, json_encode($attachment), json_encode($action_links), null, $who);
        if ($fb_post_id) {
            // update the post id so as to prevent automatically posting it twice
            update_post_meta($id, '_fb_post_id_app', $fb_post_id);
        }
    }
    // publish to profile
    if ($options['autopublish_profile'] && !get_post_meta($id, '_fb_post_id_profile', true)) {
        // check to see if we can send to FB at all
        $result = $fb->api_client->users_hasAppPermission('publish_stream');
        if (!$result) {
            break;
        }
        $fb_post_prof_id = $fb->api_client->stream_publish(null, json_encode($attachment), json_encode($action_links));
        if ($fb_post_prof_id) {
//.........这里部分代码省略.........
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:101,代码来源:sfc-publish.php

示例8: count

<?php

include 'fb/facebook.php';
$api_key = 'e59c32974d9a3136017900df131704c7';
$secret = '8d6e4b2d26b7283c473cd23d635220df';
$key = 'acaa9e7ae3c4e3ea99f107d2-45500018';
$facebook = new Facebook($api_key, $secret);
$facebook->set_user($bobby, $key);
$arrPhotos = $facebook->api_client->photos_get(45500018, '', '');
/*
for ($intI = 0; $intCounter < count($arrPhotos); $intI++)
{
	echo $arrPhotos[$intI]['src_big'] . "<br />\n";	
}
*/
echo count($arrPhotos) . '<br />';
foreach ($arrPhotos as $photo) {
    echo $photo['src_big'] . '<br />';
}
开发者ID:bobbyearl,项目名称:bobbyearl.github.io,代码行数:19,代码来源:facebook.php

示例9: die

error_reporting(E_NONE);
ini_set('display_errors', 0);
require_once '.' . DIRECTORY_SEPARATOR . 'global.php';
require_once INCLUDE_DIR . 'facebook.php';
// Workarounds for new fb rules re. iframe apps
$fb_user = $_REQUEST['uid'];
$key = $_REQUEST['key'];
$token = $_REQUEST['token'];
$secret = FB_API_SECRET;
$check = md5($fb_user . $secret);
if ($check != $token) {
    die("Invalid Signature");
}
$fb = new Facebook(FB_API_KEY, FB_API_SECRET);
$fb->set_user($fb_user, $key);
$valid_formats = array('CSV');
if (!array_key_exists('format', $_REQUEST) || !in_array($_REQUEST['format'], $valid_formats)) {
    die('Invalid format or no format specified');
}
if (is_numeric($fb_user)) {
    $info = $fb->api_client->users_getInfo($fb_user, 'name');
} else {
    die('Unable to get user info');
}
$friends = $fb->api_client->friends_get();
$all_info = $fb->api_client->users_getInfo($friends, array('uid', 'first_name', 'last_name', 'birthday', 'relationship_status', 'about_me', 'interests', 'meeting_for', 'meeting_sex', 'profile_url', 'sex'));
switch ($_REQUEST['format']) {
    case 'CSV':
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
        header('Expires: ' . gmdate("D, d M Y H:i:s", time()) . ' GMT');
开发者ID:sproates,项目名称:friendexport,代码行数:30,代码来源:export.php

示例10: delegateRequest

 /**
  * Implement delegation of requests.
  * TODO break apart the 'deployed networks' application key and the 'Social Network' application key.
  */
 function delegateRequest()
 {
     // If we are setup to use the remote trust capabilities.
     if (RingsideApiConfig::$use_facebook_trust) {
         $api_key = $this->getContext()->getApiKey();
         $call_id = $this->getContext()->getCallId();
         $sessionApiKey = $this->getSessionValue(self::SESSION_API_KEY);
         // TODO: Use trusted authN providers to establish session key; need better security delegation
         error_log("Attempting Facebook authN delegation");
         require_once "ringside/api/facebook/AuthCreateToken.php";
         require_once "ringside/api/facebook/AuthApproveToken.php";
         require_once "ringside/api/facebook/AuthGetSession.php";
         require_once "facebook/facebook.php";
         //         error_log("Validating API key $api_key");
         /** Get the secret key for given API Key */
         /** TODO It is at this point we are tied to a SINGULAR API/SECRET key. */
         $secret_key = $this->validateApiKey($api_key);
         //            error_log( "API Key is ". $api_key ." and secret is " . $secret_key);
         //            error_log("Session key provided by client is $session_key");
         if ($secret_key) {
             try {
                 // TODO: Configure trust relationships on per app basis?
                 // Delegate session creation to Facebook; then verify session authenticity by retrieving uid
                 $fb = new Facebook($api_key, $secret_key);
                 // TODO: Need to map Ringside user to Facebook user
                 $fb->set_user($user, $session_key);
                 $fb->api_client->api_key = $api_key;
                 $fb->api_client->session_key = $session_key;
                 $fb->api_client->last_call_id = $call_id;
                 // Get the remote logged in user.
                 $logged_in_user = $fb->api_client->call_method("facebook.users.getLoggedInUser", array());
                 if ($logged_in_user) {
                     // Interesting point were we sync the Social Network session with the one on this server
                     $this->setSessionValue(self::SESSION_ID, $session_key);
                     $this->setSessionValue(self::SESSION_CALL_ID, 0);
                     // TODO In the original code logged_in_user was passed into constructor, but now it's set in session.
                     $this->setSessionValue(self::SESSION_USER_ID, $logged_in_user);
                     // TODO in original code api_key was passed in, however since it's already in context, no need.
                     // TODO note everything is passed by reference, not sure if this is right.
                     // TODO this should become a BO call.
                     $forcedAuth = new AuthCreateAppSession();
                     $forcedAuth->_setContext($this->getContext());
                     $forcedAuth->_setSession($this->getSession());
                     $forcedAuth->_setServer($this->getServer());
                     $forcedAuth->validateRequest();
                     $forcedAuthResponse = $forcedAuth->execute();
                     //                  error_log(var_export($authGetSessionResponse, true));
                     if (!$authGetSessionResponse['session_key']) {
                         throw new OpenFBAPIException("Unable to get Ringside session for Facebook delegation");
                     }
                     //                  error_log("Started Ringside session using key ".$authGetSessionResponse['session_key']);
                     error_log("Authenticated via Facebook trust to Facebook uid {$logged_in_user}");
                     // TODO: Map to Ringside PID here!
                     //                     $this->validateCallId ( $call_id );
                     //                     error_log("Validated Facebook-authenticated call_id");
                     return;
                 } else {
                     error_log("Failed to authenticate via Facebook trust");
                 }
             } catch (FacebookRestClientException $e) {
                 error_log("Facebook trust authentication failed: " . $e->getMessage());
                 error_log($e->getTraceAsString());
             }
         } else {
             error_log("Application with API key " + $api_key + " is not registered for Facebook trust");
         }
     }
 }
开发者ID:jkinner,项目名称:ringside,代码行数:72,代码来源:DefaultRest.php


注:本文中的Facebook::set_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。