This proposal aims to introduce an integration that verifies the number of likes on a tweet containing a specific hashtag. This service will allow users to link their Twitter accounts and retrieve the number of likes on their tweets with specified hashtags. This feature enhances our application by providing users with deeper insights into the engagement their tweets receive based on specific topics.
External APIs Needed
Twitter API
Reclaim API
Use Cases
Marketing Analysis: Marketers can track the performance of their campaigns by monitoring likes on tweets with campaign-specific hashtags.
Content Creators: Influencers and content creators can measure the engagement of their posts related to particular topics or trends.
Research: Researchers can analyze public sentiment and engagement on tweets associated with specific hashtags.
Data Provider
Name: Twitter
Hash Value:
Code Snippet
utils/constants.js
exports.RECLAIM_PROVIDER_ID = {
twitter: 'TWITTER_ANALYTICS_VIEWS',
github: 'GITHUB_ACCOUNT_VERIFICATION',
tweetLikes: 'TWEET_LIKES_VERIFICATION', // Added for the new service
}
exports.RECLAIM_APP_ID = {
TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id',
GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id',
TWEET_LIKES_VERIFICATION: 'your-tweet-likes-app-id', // Added for the new service
}
Title
Tweet Likes Verification Service
Introduction
This proposal aims to introduce an integration that verifies the number of likes on a tweet containing a specific hashtag. This service will allow users to link their Twitter accounts and retrieve the number of likes on their tweets with specified hashtags. This feature enhances our application by providing users with deeper insights into the engagement their tweets receive based on specific topics.
External APIs Needed
Twitter API Reclaim API
Use Cases
Marketing Analysis: Marketers can track the performance of their campaigns by monitoring likes on tweets with campaign-specific hashtags. Content Creators: Influencers and content creators can measure the engagement of their posts related to particular topics or trends. Research: Researchers can analyze public sentiment and engagement on tweets associated with specific hashtags.
Data Provider
Name: Twitter Hash Value:
Code Snippet
utils/constants.js exports.RECLAIM_PROVIDER_ID = { twitter: 'TWITTER_ANALYTICS_VIEWS', github: 'GITHUB_ACCOUNT_VERIFICATION', tweetLikes: 'TWEET_LIKES_VERIFICATION', // Added for the new service }
exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', TWEET_LIKES_VERIFICATION: 'your-tweet-likes-app-id', // Added for the new service }
services/reclaimService.js
const axios = require('axios') const { Reclaim } = require('@reclaimprotocol/js-sdk') const { RECLAIM_PROVIDER_ID, RECLAIM_APP_ID } = require('../utils/constants') const { processTwitterData } = require('./twitterService') const { processGitHubData } = require('./githubService') const { processTweetLikesData } = require('./tweetLikesService') // Import the new service
exports.signWithProviderID = async (userId, providerId) => { const providerName = RECLAIM_PROVIDER_ID[providerId] const reclaimAppID = RECLAIM_APP_ID[providerName] const reclaimAppSecret = process.env[
${providerName}_SECRET
]console.log(
Sending signature request to Reclaim for userId: ${userId} with providerName: ${providerName}
)try { const reclaimClient = new Reclaim.ProofRequest(reclaimAppID) await reclaimClient.buildProofRequest(providerId) reclaimClient.setSignature( await reclaimClient.generateSignature(reclaimAppSecret) ) const { requestUrl: signedUrl } = await reclaimClient.createVerificationRequest()
} catch (error) { console.error(
Failed to process Reclaim request for userId: ${userId}
, error ) throw error } }const handleReclaimSession = async (userId, reclaimClient, providerName) => { await reclaimClient.startSession({ onSuccessCallback: async proof => { console.log(
Successful reclaim callback with proof: ${JSON.stringify(proof)}
)}) }
services/tweetLikesService.js
const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse')
exports.processTweetLikesData = async (proof, providerName) => { // Extract relevant data from the proof const tweetData = JSON.parse(proof[0].claimData.context).extractedParameters const tweetLikes = tweetData.likes const tweetHashtag = tweetData.hashtag const tweetId = tweetData.tweetId
// Process the extracted data const tweetLikesValue = tweetLikes.match(/likes=\"([\d,]+)/)[1].replace(/,/g, '')
// Extract additional relevant data from the proof const url = JSON.parse(proof[0].claimData.parameters).url const matchurl = url.match(/user\/([^\/]+)/) const username = matchurl ? matchurl[1] : null const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS)
// Create a ReclaimServiceResponse object with the processed data
return new ReclaimServiceResponse( providerName, lastUpdateTimeStamp, username, parseInt(tweetLikesValue, 10), proof[0] ) }
utils/reclaimServiceResponse.js
class ReclaimServiceResponse { constructor(flag, timestamp, userName, targetValue, data) { this.flag = flag this.timestamp = timestamp this.userName = userName this.targetValue = targetValue this.data = data } }
module.exports = { ReclaimServiceResponse }