{"id":25480194,"url":"https://github.com/victoku1/social-network-analyzer","last_synced_at":"2026-05-07T11:31:10.527Z","repository":{"id":277219447,"uuid":"917342253","full_name":"VictoKu1/Social-Network-Analyzer","owner":"VictoKu1","description":"Social Network Analyzer is a Flask-powered app that combines AI-driven insights with social media links (e.g., Twitter, Instagram). Validate profiles, add user context, and receive intelligent personality summaries via OpenAI’s cutting-edge models. Perfect for exploring the power of AI in an interactive way!","archived":false,"fork":false,"pushed_at":"2026-04-12T16:25:49.000Z","size":153,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-12T18:12:44.323Z","etag":null,"topics":["ai","api-integration","backend","data-analysis","flask","frontend","information-extraction","oauth","openai","psycology","python","social-media","social-network","social-network-analysis","web-scraping"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VictoKu1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-15T19:58:21.000Z","updated_at":"2025-12-09T16:59:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"0fd46cf9-abac-440f-a294-fd56c1512d88","html_url":"https://github.com/VictoKu1/Social-Network-Analyzer","commit_stats":null,"previous_names":["victoku1/social-network-analyzer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VictoKu1/Social-Network-Analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictoKu1%2FSocial-Network-Analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictoKu1%2FSocial-Network-Analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictoKu1%2FSocial-Network-Analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictoKu1%2FSocial-Network-Analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VictoKu1","download_url":"https://codeload.github.com/VictoKu1/Social-Network-Analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictoKu1%2FSocial-Network-Analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32735072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api-integration","backend","data-analysis","flask","frontend","information-extraction","oauth","openai","psycology","python","social-media","social-network","social-network-analysis","web-scraping"],"created_at":"2025-02-18T15:38:39.099Z","updated_at":"2026-05-07T11:31:10.520Z","avatar_url":"https://github.com/VictoKu1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Social Network Analyzer\n\n[![Pylint](https://github.com/VictoKu1/Social-Network-Analyzer/actions/workflows/pylint.yml/badge.svg)](https://github.com/VictoKu1/Social-Network-Analyzer/actions/workflows/pylint.yml)\n\nThis repository contains a **Flask-based web application** that lets users:\n\n1. **Specify how many social network links** they want to analyze.\n2. Enter and **validate** each link (Twitter, Instagram, Facebook, Threads, etc.).\n3. Provide a **personal description** about the person whose profiles are being analyzed.\n4. **Analyze** all collected data (links + description) via the OpenAI API to generate a **personality overview** or short psychological summary.\n\n\u003e **IMPORTANT DISCLAIMER**  \n\u003e - This is **not** a clinical or professional psychological tool.  \n\u003e - The output can contain errors or \"hallucinations\" typical of Large Language Models.  \n\u003e - Always comply with each social platform's terms of service regarding data collection/scraping.  \n\u003e - Handle personal data with caution and respect user privacy.\n\n---\n\n## 🚀 New Features: Platform-Specific API Integration\n\nThe application now includes **advanced platform-specific API integration** for reliable social media data fetching:\n\n### ✅ Supported Platforms\n- **Twitter/X**: Full API v2 and v1.1 support with rate limiting\n- **LinkedIn**: Profile data extraction with authentication\n- **Instagram**: Public and private profile access via instaloader\n- **Facebook**: Graph API integration for profile data\n- **Reddit**: User data and post history via PRAW\n- **Generic Platforms**: Web scraping fallback for other platforms\n\n### 🔧 Key Improvements\n- **Rate Limiting**: Automatic API rate limit management\n- **Authentication**: OAuth and API key support for each platform\n- **Fallback Mechanisms**: Web scraping when APIs are unavailable\n- **Structured Data**: Consistent data format across all platforms\n- **Error Handling**: Comprehensive error handling and recovery\n\n### 📊 Enhanced Data Extraction\n- Profile information (name, bio, location, website)\n- Follower/following counts\n- Verification status\n- Recent posts and activity\n- Account creation dates\n- Profile pictures\n\nFor detailed setup instructions, see [API_INTEGRATION_GUIDE.md](API_INTEGRATION_GUIDE.md).\n\n---\n\n## Features\n\n- **Multi-Step Flow**  \n  - **Step A**: Select the number of social network links.  \n  - **Step B**: Enter each link, then validate it against known social platforms.  \n    - If all links are valid, you can continue. Otherwise, you must correct them.  \n  - **Step C**: Provide a personal description for additional context.  \n  - **Analysis**: The server combines the links + personal description into a prompt, sends it to OpenAI, and displays a final summary.\n\n- **Dynamic Frontend**  \n  - Uses JavaScript (Fetch API) to handle link validation and multi-step UI.  \n  - Displays **✓** for valid links and **✗** for invalid links.\n\n- **OpenAI Integration**  \n  - A sample prompt demonstrates how to create a short \"personality analysis.\"  \n  - Requires an **OpenAI API key** (set in `.env` or as an environment variable).\n\n- **Platform-Specific API Integration**  \n  - Reliable data fetching using official APIs where available\n  - Automatic fallback to web scraping for unsupported platforms\n  - Rate limiting and error handling for robust operation\n\n---\n\n## Quickstart\n\n1. **Clone the Repository**:\n\n   ```\n   git clone https://github.com/VictoKu1/Social-Network-Analyzer.git\n   cd Social-Network-Analyzer\n    ```\n\n2. **Install Dependencies**:\n\n   - **Python 3.8+** recommended.\n   - Install packages:\n\n    ```\n    pip install -r requirements.txt\n    ```\n\n3. **Set Your API Keys**:\n\n    Create a `.env` file with your API credentials:\n\n    ```env\n    # Required: OpenAI API\n    OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxx\n    \n    # Optional: Platform-specific APIs (see config_example.py for details)\n    TWITTER_BEARER_TOKEN=your_twitter_bearer_token\n    LINKEDIN_EMAIL=your_linkedin_email\n    LINKEDIN_PASSWORD=your_linkedin_password\n    INSTAGRAM_USERNAME=your_instagram_username\n    INSTAGRAM_PASSWORD=your_instagram_password\n    FACEBOOK_ACCESS_TOKEN=your_facebook_access_token\n    REDDIT_CLIENT_ID=your_reddit_client_id\n    REDDIT_CLIENT_SECRET=your_reddit_client_secret\n    ```\n\n    **Note**: Only the OpenAI API key is required. Platform-specific APIs are optional and will fall back to web scraping if not provided.\n\n4. **Run the Flask App**:\n\n    ```\n    python app.py\n    ```\n\n5. **Open Your Browser**:\n\nVisit http://127.0.0.1:5000/ to access the web app.\n\n6. **Test the API Integration** (Optional):\n\n    ```\n    python test_api_integration.py\n    ```\n\n---\n\n## Usage\n1. **Step A**: Select the number of social profiles (e.g., 2).\n2. **Step B**: Enter each URL in the generated fields (e.g., https://x.com/example), then click **Validate Links**.\n * If a link is marked ✗, correct it.\n * If all links are ✓, the Continue button appears.\n3. **Step C**: Provide a **personal description** for context (e.g., \"She is very outgoing and enjoys discussing tech trends.\").\n4. **Click** ```Analyze```: The server sends the data to OpenAI and displays a final summary.\n\nThe application will now use platform-specific APIs when available, providing more reliable and comprehensive data extraction.\n\n---\n\n## Project Structure\n\n```\n.\n├── static/             \n│   └── css/\n│       └── style.css    # CSS for the multi-step form\n├── js/                 \n│   └── app.js          # JavaScript for the multi-step form\n├── templates/\n│   └── index.html      # Implements the multi-step form using JavaScript\n├── app.py              # Main Flask app with routes\n├── analyze.py          # OpenAI-related analysis logic (link validation, prompt construction)\n├── social_media_fetchers.py  # NEW: Platform-specific API integration\n├── test_analyze.py     # Unit tests for the analyze.py logic\n├── test_api_integration.py   # NEW: API integration tests\n├── config_example.py   # NEW: Example configuration file\n├── API_INTEGRATION_GUIDE.md  # NEW: Comprehensive API setup guide\n├── requirements.txt    # Python package dependencies\n├── README.md           # This README file\n├── LICENSE             # License (MIT)\n└── .gitignore          # Prevents committing unwanted files\n```\n\n- ```app.py```: \n  - Defines the Flask routes:\n    - ```GET /``` serves the main page (```index.html```)\n    - ```POST /validate_links``` checks if each link is a recognized social network\n    - ```POST /analyze``` calls the analysis function in ```analyze.py``` and returns the result\n\n- ```analyze.py```:\n  - Contains the core **OpenAI analysis** logic:\n    - ```validate_social_link(link)``` checks if a URL is recognized (Twitter, Instagram, etc.).\n    - ```analyze_personality(links_info, personal_description)``` constructs a prompt and calls the OpenAI API.\n    - **Updated** to use platform-specific fetchers for better data extraction.\n\n- ```social_media_fetchers.py```: **NEW**\n  - Platform-specific API integration for Twitter, LinkedIn, Instagram, Facebook, and Reddit\n  - Rate limiting and error handling\n  - Fallback mechanisms for unsupported platforms\n  - Structured data extraction and formatting\n\n- ```test_analyze.py```:\n  - Contains **unit tests** for functions in ```analyze.py```.\n  - Uses Python's built-in ```unittest``` or can be adapted for ```pytest```.\n\n- ```test_api_integration.py```: **NEW**\n  - Tests for the platform-specific API integration\n  - Demonstrates the difference between old and new fetching methods\n  - Validates rate limiting and error handling\n\n- ```config_example.py```: **NEW**\n  - Example configuration file showing all required API credentials\n  - Detailed setup instructions for each platform\n  - Security best practices\n\n- ```API_INTEGRATION_GUIDE.md```: **NEW**\n  - Comprehensive guide for setting up platform-specific APIs\n  - Troubleshooting and performance optimization tips\n  - Security considerations and best practices\n\n- ```Templates/index.html```:\n  - Implements the **multi-step form** using JavaScript.\n  - Uses the Fetch API to call ```/validate_links``` and ```/analyze```.\n\n- ```requirements.txt```:\n  - Python package dependencies.\n  - **Updated** to include platform-specific API libraries.\n\n- ```.gitignore```:\n  - Hides temporary or sensitive files (e.g., ```venv/```, ```.env```, ```__pycache__```, etc.) from version control.\n\n---\n\n## Testing\n\nTo run the **unit tests** for ```analyze.py```, use one of the following:\n\n### Using Python's built-in ```unittest```\n\n```\npython -m unittest discover\n```\n\nor specifically:\n\n```\npython -m unittest test_analyze.py\n````\n\n### Using ```pytest``` (if installed)\n```\npytest\n```\n\n### Testing API Integration (NEW)\n\n```\npython test_api_integration.py\n```\n\nTests in ```test_analyze.py```:\n\n- **Mock** the OpenAI API to avoid real API calls.\n- Verify that functions like ```validate_social_link``` and ```analyze_personality``` behave as expected.\n\nTests in ```test_api_integration.py```:\n\n- **Compare** old generic fetching with new platform-specific fetching\n- **Validate** rate limiting and error handling\n- **Test** platform detection and username extraction\n- **Verify** fallback mechanisms work correctly\n\n---\n\n## API Setup\n\nFor detailed instructions on setting up platform-specific APIs, see [API_INTEGRATION_GUIDE.md](API_INTEGRATION_GUIDE.md).\n\n### Quick Setup Summary\n\n1. **Twitter/X**: Get API keys from [Twitter Developer Portal](https://developer.twitter.com/en/portal/dashboard)\n2. **LinkedIn**: Use email/password (not recommended for production)\n3. **Instagram**: Use username/password for private profiles\n4. **Facebook**: Get access token from [Facebook Developers](https://developers.facebook.com/)\n5. **Reddit**: Create app at [Reddit App Preferences](https://www.reddit.com/prefs/apps)\n\n### Security Notes\n\n- Never commit API keys to version control\n- Use environment variables for sensitive data\n- Regularly rotate your API keys\n- Monitor API usage to avoid rate limits\n\n---\n\n## Contributing\n\n1. **Fork** this repo and clone your fork.\n2. **Create** a new branch for your feature/bugfix:\n```\ngit checkout -b feature/new-stuff\n```\n\n3. **Commit** and push your changes:\n```\ngit commit -m \"Add new feature\"\ngit push origin feature/new-stuff\n```\n\n4. **Open** a Pull Request on GitHub.\n\n---\n\n## License\n\n\nPlease see the [LICENSE](LICENSE) file for details.\n\n\n## Disclaimer\n\n- This software is provided \"as is,\" without any warranty or guarantee.\n- Always comply with social media platforms' terms of service and API usage policies.\n- Respect user privacy and data protection regulations.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictoku1%2Fsocial-network-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictoku1%2Fsocial-network-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictoku1%2Fsocial-network-analyzer/lists"}