jdark-facebook-sdk
v2.0.5
Published
Facebook SDK with proxy support(Cookies)
Readme
JdarkSdk
A powerful Node.js SDK for interacting with Facebook's API, providing easy access to posts, profiles, and reactions.
Features
- Easy Facebook API integration
- Load single posts with detailed information
- Fetch profile feeds with pagination
- React to posts (Like, Love, etc.)
- Cookie-based authentication
- Proxy support
- Debug mode for development
Installation
npm install jdark-facebook-sdkQuick Start
const { JdarkSdk } = require('jdark-facebook-sdk');
// Initialize SDK with cookies
const sdk = new JdarkSdk('your_facebook_cookies_string');
// With proxy support
const sdk = new JdarkSdk('your_facebook_cookies_string', 'http://proxy:port');
// Initialize the SDK
const isInitialized = await sdk.initialize();
if (isInitialized) {
console.log('SDK initialized successfully!');
}API Reference
Constructor
new JdarkSdk(cookies_str, proxy = null)Methods
initialize()
Initializes the SDK and validates Facebook tokens.
encode(data, type)
Encodes data for Facebook operations.
// Encode for single post
const encoded = sdk.encode({ postId: 'POST_ID', profileId: 'PROFILE_ID' }, 'singlepost');
// Encode for reactions
const encoded = sdk.encode({ postId: 'POST_ID' }, 'feedback');postSingle(storyID)
Loads detailed information for a single post.
const postData = await sdk.postSingle('ENCODED_STORY_ID');postFeedProfile(profileId, cursor = "")
Fetches posts from a profile's feed with pagination support.
// First page
const feed = await sdk.postFeedProfile('PROFILE_ID');
// Next page with cursor
const nextFeed = await sdk.postFeedProfile('PROFILE_ID', 'CURSOR_TOKEN');reactorPost()
Provides access to post reaction functionality. reactionType : LIKE|LOVE|HAHA|WOW|SAD|ANGRY
const reactor = await sdk.reactorPost();searchPage(searchPage, cursor = "")
Search for pages and profiles.
const results = await sdk.searchPage('search_term');Usage Examples
Complete Example
const { JdarkSdk } = require('jdark-facebook-sdk');
(async () => {
// Initialize SDK
const sdk = new JdarkSdk('your_facebook_cookies');
const isReady = await sdk.initialize();
if (!isReady) {
console.error('Failed to initialize SDK');
return;
}
try {
// Load a single post
const storyId = sdk.encode({
postId: 'POST_ID',
profileId: 'PROFILE_ID'
}, 'singlepost');
const post = await sdk.postSingle(storyId);
console.log('Post data:', post);
// Get profile feed
const profileFeed = await sdk.postFeedProfile('PROFILE_ID');
console.log('Profile feed:', profileFeed);
// Search for pages
const searchResults = await sdk.searchPage('search_term');
console.log('Search results:', searchResults);
} catch (error) {
console.error('Error:', error);
}
})();Profile Feed Scanning
async function scanProfile(profileId) {
const sdk = new JdarkSdk('your_cookies');
await sdk.initialize();
let cursor = '';
let allPosts = [];
do {
const feed = await sdk.postFeedProfile(profileId, cursor);
allPosts.push(...feed.posts);
cursor = feed.nextCursor;
console.log(`Loaded ${feed.posts.length} posts`);
} while (cursor);
return allPosts;
}Error Handling
try {
const sdk = new JdarkSdk('cookies');
const success = await sdk.initialize();
if (!success) {
throw new Error('SDK initialization failed');
}
const post = await sdk.postSingle('story_id');
} catch (error) {
console.error('SDK Error:', error.message);
}Security Notes
- Never commit Facebook cookies to version control
- Use environment variables for sensitive data
- Respect Facebook's Terms of Service
- Implement rate limiting to avoid being blocked
Requirements
- Node.js 12+
- Valid Facebook session cookies
- Internet connection
Donation
If this SDK helps you, consider supporting development:
PayPal: [email protected]
License
This project is for educational purposes only. Please respect Facebook's Terms of Service and use responsibly.
Disclaimer
This SDK is not officially associated with Facebook/Meta. Use at your own risk and ensure compliance with Facebook's Terms of Service.
