Example #1
0
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'RESET') {
    ValidateParamCount(0);
    VerifyOutputDir($fbcmdPrefs['keyfile']);
    if (@file_put_contents($fbcmdPrefs['keyfile'], "EMPTY\nEMPTY\n# only the first two lines of this file are read\n# use fbcmd RESET to replace this file\n") == false) {
        FbcmdFatalError("Could not generate keyfile {$fbcmdPrefs['keyfile']}");
    }
    if (!$fbcmdPrefs['quiet']) {
        print "keyfile {$fbcmdPrefs['keyfile']} has been RESET\n";
    }
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'AUTH') {
    ValidateParamCount(1);
    try {
        $fbObject = new FacebookDesktop($fbcmdPrefs['appkey'], $fbcmdPrefs['appsecret']);
        $session = $fbObject->do_get_session($fbcmdParams[1]);
        TraceReturn($session);
    } catch (Exception $e) {
        FbcmdException($e, 'Invalid AUTH code / could not authorize session');
    }
    $fbcmdUserSessionKey = $session['session_key'];
    $fbcmdUserSecretKey = $session['secret'];
    VerifyOutputDir($fbcmdPrefs['keyfile']);
    if (@file_put_contents($fbcmdPrefs['keyfile'], "{$fbcmdUserSessionKey}\n{$fbcmdUserSecretKey}\n# only the first two lines of this file are read\n# use fbcmd RESET to replace this file\n") == false) {
        FbcmdFatalError("Could not generate keyfile {$fbcmdPrefs['keyfile']}");
    }
    try {
        $fbObject->api_client->session_key = $fbcmdUserSessionKey;
        $fbObject->secret = $fbcmdUserSecretKey;
        $fbObject->api_client->secret = $fbcmdUserSecretKey;
#!/usr/bin/php
<?php 
if (!$argv[0] || !$argv[1] || !$argv[2] || !$argv[3]) {
    print "./step_two.php <api_key> <app secret> <auth_token>\n";
    exit;
}
$api_key = $argv[1];
$secret = $argv[2];
$auth_token = $argv[3];
include_once 'lib/client/facebook.php';
include_once 'lib/client/facebook_desktop.php';
$client = new FacebookDesktop($api_key, $secret);
$result = $client->do_get_session($auth_token);
print "Be sure to keep the session key and secret in a safe place!!\n\n";
print "Session: " . $result['session_key'] . "\n";
print "User ID: " . $result['uid'] . "\n";
print "Expires: " . $result['expires'] . "\n";
print "Application Secret: " . $secret . "\n";
print "Session Secret: " . $result['secret'] . "\n\n";
print 'Executing query: SELECT concat(name, " is ", relationship_status) FROM user WHERE uid = ' . $result['uid'] . "\n\n";
$resp = $client->api_client->fql_query('SELECT concat(name, " is ", relationship_status) FROM user WHERE uid = ' . $result['uid']);
var_dump($resp);
Example #3
0
<?php

// Replace the data below, calculate your keys and insert them into index.php if the provided keys in index.php stop working.
// Before you authenticate with your own keys, make SURE that your app is set to "desktop" rather than "webapp" in the settings,
// otherwise php will complain about there being no 'secret' in the returned session.
require_once 'facebook/facebook.php';
require_once 'facebook/facebook_desktop.php';
$appkey = 'd678757449ec0c4040b045b803c96f5c';
$appsecret = 'f5d30da3c19f9cd7816d1bb0f7595a55';
$fbObject = new FacebookDesktop($appkey, $appsecret);
$session = $fbObject->do_get_session("BFNP4B");
// replace this with the data you get from http://www.facebook.com/code_gen.php?v=1.0&api_key=$appkey
$photobombUserSessionKey = $session['session_key'];
$photobombUserSecretKey = $session['secret'];
echo $photobombUserSessionKey . '\\n';
echo $photobombUserSecretKey . '\\n';
try {
    $fbObject->api_client->session_key = $photobombUserSessionKey;
    $fbObject->secret = $photobombUserSecretKey;
    $fbObject->api_client->secret = $photobombUserSecretKey;
    $fbUser = $fbObject->api_client->users_getLoggedInUser();
    $fbReturn = $fbObject->api_client->users_getInfo($fbUser, array('name'));
} catch (Exception $e) {
    echo 'Invalid AUTH code / could not generate session key';
}
Example #4
0
function upload_strings($api_key, $secret, $input)
{
    $strings = get_strings($input);
    print_strings($strings);
    $cnt = count($strings);
    if ($cnt < 1) {
        echo "No strings found. Exiting.\n";
        exit;
    }
    echo "\nThe {$cnt} string(s) above will be uploaded.\n";
    echo "To exit now, use Ctrl-C.\n";
    $facebook = new FacebookDesktop($api_key, $secret);
    $auth_token = $facebook->api_client->auth_createToken();
    $login_url = build_url($api_key, $auth_token);
    `open "{$login_url}"`;
    do {
        echo "Otherwise, type 'y' to continue after logging into Facebook.\n";
    } while (!(strtolower(fgets(STDIN)) === "y\n"));
    if (null == $facebook->do_get_session($auth_token)) {
        echo "Could not obtain Facebook session. Exiting.\n";
        exit;
    }
    $unescaped_strings = unescape_c_strings($strings);
    $num_strings = $facebook->api_client->intl_uploadNativeStrings($unescaped_strings);
    if (!$num_strings) {
        echo "Oops. Sorry, failed to upload.\n";
    } else {
        echo "{$num_strings} string(s) uploaded successfully.\n";
    }
}