Download the PHP package luizsilva-dev/cj-sdk-php without Composer
On this page you can find all versions of the php package luizsilva-dev/cj-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download luizsilva-dev/cj-sdk-php
More information about luizsilva-dev/cj-sdk-php
Files in luizsilva-dev/cj-sdk-php
Package cj-sdk-php
Short Description Complete PHP SDK for CJ Affiliate API - Product Search, Advertiser Lookup, Commission Tracking, Link Search and more
License MIT
Homepage https://github.com/luizsilva-dev/cj-sdk-php
Informations about the package cj-sdk-php
CJ Affiliate SDK for PHP
A comprehensive and fully tested PHP SDK for integrating with the CJ Affiliate (Commission Junction) API. Built with Guzzle HTTP client and tested with real CJ credentials to ensure 100% compatibility.
Developed by: Luiz Silva
🚀 Features
- ✅ Link Search API - Search affiliate links with product information
- ✅ Advertiser Lookup - Search and discover advertisers/merchants
- ✅ Commission Detail - Real-time commission tracking via GraphQL
- ✅ Program Terms - Access program commission rates
- ✅ Promotional Properties - Manage PIDs and tracking
- ✅ Offer Feed - Access automated offers
- ✅ Built-in Caching - File-based caching for performance
- ✅ XML & JSON Support - Automatic format detection
- ✅ Exception Handling - Comprehensive error handling
- ✅ Guzzle HTTP Client - Modern and reliable
- ✅ PSR-4 Autoloading - Modern PHP standards
⚠️ Important Note About Product Search
CJ Affiliate does not offer a public Product Search API.
After extensive testing with real CJ credentials, we confirmed that:
- The GraphQL Product Search endpoint (
ads.api.cj.com/graphql) does not exist (404 error) - Product Feeds are for advertisers to submit products, not for publishers to query
Solution: Use the Link Search API instead. It returns affiliate links that include product information (names, URLs, commissions, etc.).
See API_CHANGES.md for details.
💻 Requirements
- PHP 7.4 or higher
- JSON extension enabled
- XML extension enabled
- Guzzle HTTP client (auto-installed via Composer)
- CJ Affiliate account with API credentials
📦 Installation
Via Composer (Recommended)
Manual Installation
Then include in your project:
⚡ Quick Start
1. Get Your CJ API Credentials
- Visit CJ Developer Portal
- Sign in with your CJ Affiliate credentials
- Go to Authentication > Personal Access Tokens
- Create a new token
- Copy your Personal Access Token
- Get your Publisher ID (top right corner in CJ Members portal)
- Get your Website ID from Account → Websites
2. Initialize the Client
3. Search Affiliate Links
📖 API Reference
Link Search (Product Information)
The products() method actually uses the Link Search API, which returns affiliate links with product information:
Response:
Advertiser Lookup
Response:
Commission Details
Response:
Program Terms
Promotional Properties
🎯 Examples
See the examples/ directory for complete working examples:
- example_products.php - Link search
- example_advertisers.php - Advertiser lookup
- example_commissions.php - Commission tracking
- example_error_handling.php - Error handling
- example_debug.php - Debug mode
⚙️ Configuration
Caching
Enable caching to reduce API calls:
Debug Mode
Enable debug mode to see request/response details:
Debug logs will be written to PHP's error log.
Timeout
Adjust request timeout:
🚨 Error Handling
The SDK throws CJException for all errors:
Common Errors
| Error | Cause | Solution |
|---|---|---|
| HTTP 400 | Invalid parameters | Check parameter names and values |
| HTTP 401 | Invalid access token | Generate a new token at developers.cj.com |
| HTTP 403 | No API access | Contact CJ Affiliate support |
| HTTP 404 | Endpoint not found | Update SDK to latest version |
| HTTP 406 | Invalid request format | Check access token format |
🎨 Performance Tips
- Enable Caching: Reduces API calls significantly
- Batch Requests: Request multiple items in single calls
- Pagination: Use
records_per_pageto limit response size - Filter Results: Use specific parameters to reduce data transfer
- Connection Pooling: Reuse the same client instance
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Development Setup
Running Tests
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
💬 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
🔗 Useful Links
📝 Changelog
See CHANGELOG.md for a history of changes to this project.
🙏 Acknowledgments
- Built with Guzzle HTTP Client
- Tested with real CJ Affiliate credentials to ensure accuracy
- Special thanks to the CJ Affiliate API team
Made with ❤️ by Luiz Silva
All versions of cj-sdk-php with dependencies
ext-json Version *
ext-xml Version *
ext-simplexml Version *
guzzlehttp/guzzle Version ^7.0