Closed mcfang closed 3 months ago
Here is my code:
const client = new NeynarAPIClient(''); const messageDataOptions = { fid: 749199, network: FarcasterNetwork.MAINNET }; const privateKey = ''; const ed25519Signer = new NobleEd25519Signer( Buffer.from(privateKey, "hex") ); client.fetchBulkUsers([658010], {viewerFid: 749199}).then((res2) => { console.log(`fetch user--- ${JSON.stringify(res2)}`) console.log(res2.users[0].viewer_context?.following) if (res2.users[0].viewer_context?.following) { console.log(`following`) makeLinkRemove({ type: "unfollow", targetFid: 658010 }, messageDataOptions, ed25519Signer).then((res) => { console.log(`unfollow user--- ${JSON.stringify(res)}`) if (res) { client.publishMessageToFarcaster(Message.toJSON(res.unwrapOr(null) as Message)!).then((res1) => { console.log(`unfollow publish message--- ${JSON.stringify(res1)}`) client.fetchBulkUsers([658010], {viewerFid: 749199}).then((res3) => { console.log(`fetch user again--- ${JSON.stringify(res2)}`) }) }); } }) } else { console.log(`unfollow`) makeLinkAdd({ type: "follow", targetFid: 18407 }, messageDataOptions, ed25519Signer).then((res) => { console.log(`follow user--- ${JSON.stringify(res)}`) if (res) { client.publishMessageToFarcaster(Message.toJSON(res.unwrapOr(null) as Message)!).then((res1) => { console.log(`follow publish message--- ${JSON.stringify(res1)}`) client.fetchBulkUsers([18407], {viewerFid: 749199}).then((res3) => { console.log(`fetch user again--- ${JSON.stringify(res2)}`) }) }); } }) } })
Output is :
fetch user--- {"users":[{"object":"user","fid":658010,"custody_address":"0x30596788b4688f33aeffce6f593d9979ef0acce8","username":"0xpokerface","display_name":"PokerFace","pfp_url":"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/06ff57c6-2f09-4e11-8529-0f761126c500/rectcrop3","profile":{"bio":{"text":""}},"follower_count":15,"following_count":5,"verifications":[],"verified_addresses":{"eth_addresses":[],"sol_addresses":[]},"active_status":"inactive","power_badge":false,"viewer_context":{"following":true,"followed_by":true}}]} true following unfollow user--- {"value":{"data":{"type":6,"fid":749199,"timestamp":111925067,"network":1,"linkBody":{"type":"unfollow","targetFid":658010}},"hash":{"0":54,"1":143,"2":43,"3":111,"4":203,"5":9,"6":8,"7":98,"8":126,"9":49,"10":105,"11":92,"12":210,"13":184,"14":120,"15":167,"16":53,"17":231,"18":67,"19":4},"hashScheme":1,"signature":{"0":102,"1":52,"2":153,"3":209,"4":148,"5":210,"6":45,"7":139,"8":74,"9":33,"10":115,"11":14,"12":14,"13":108,"14":77,"15":88,"16":27,"17":179,"18":64,"19":17,"20":166,"21":46,"22":190,"23":251,"24":30,"25":75,"26":212,"27":24,"28":5,"29":248,"30":136,"31":102,"32":246,"33":210,"34":66,"35":120,"36":74,"37":90,"38":14,"39":154,"40":176,"41":114,"42":29,"43":176,"44":208,"45":62,"46":143,"47":145,"48":98,"49":39,"50":188,"51":156,"52":86,"53":146,"54":62,"55":125,"56":139,"57":238,"58":248,"59":87,"60":80,"61":233,"62":112,"63":8},"signatureScheme":1,"signer":{"0":75,"1":75,"2":24,"3":86,"4":218,"5":68,"6":154,"7":159,"8":66,"9":43,"10":190,"11":82,"12":234,"13":102,"14":245,"15":17,"16":11,"17":120,"18":121,"19":1,"20":237,"21":40,"22":191,"23":116,"24":183,"25":16,"26":126,"27":141,"28":236,"29":143,"30":120,"31":8}}} unfollow publish message--- {"data":{"type":6,"fid":749199,"timestamp":111925067,"network":1,"linkBody":{"type":"unfollow","targetFid":658010}},"hash":{"type":"Buffer","data":[54,143,43,111,203,9,8,98,126,49,105,92,210,184,120,167,53,231,67,4]},"hashScheme":1,"signature":{"type":"Buffer","data":[102,52,153,209,148,210,45,139,74,33,115,14,14,108,77,88,27,179,64,17,166,46,190,251,30,75,212,24,5,248,136,102,246,210,66,120,74,90,14,154,176,114,29,176,208,62,143,145,98,39,188,156,86,146,62,125,139,238,248,87,80,233,112,8]},"signatureScheme":1,"signer":{"type":"Buffer","data":[75,75,24,86,218,68,154,159,66,43,190,82,234,102,245,17,11,120,121,1,237,40,191,116,183,16,126,141,236,143,120,8]}} fetch user again--- {"users":[{"object":"user","fid":658010,"custody_address":"0x30596788b4688f33aeffce6f593d9979ef0acce8","username":"0xpokerface","display_name":"PokerFace","pfp_url":"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/06ff57c6-2f09-4e11-8529-0f761126c500/rectcrop3","profile":{"bio":{"text":""}},"follower_count":15,"following_count":5,"verifications":[],"verified_addresses":{"eth_addresses":[],"sol_addresses":[]},"active_status":"inactive","power_badge":false,"viewer_context":{"following":true,"followed_by":true}}]}
follow and unfollow function deos not work.
makeLinkRemove({ type: "unfollow", targetFid: 658010 }, type param error. Sorry.
Here is my code:
Output is :
follow and unfollow function deos not work.