Twitter API v2 Batch compliance (Compliance Firehose API) does not know how to upload to Google API Storage

Asked 2 years ago, Updated 2 years ago, 378 views

I'm trying to do Twitter Batch compliance (Compliance Firehose API), but I was able to create a job in step 1, and I got upload_url, but I don't know how to upload the file in step 2.

The contents of the file seem to need a list of Tweet ID or User ID, but I don't know how to upload the file (data) to upload_url.

What should I do?

let url=URL(string:"https://storage.googleapis.com/twttr-tweet-compliance/1579097950700961793/submission/1468034183536984067_1579097950700961793?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=complianceapi-public-svc-acct%40twttr-compliance-public-prod.iam.gserviceaccount.com%2F20221009%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20221009T131424Z&X-Goog-Expires=900&X-Google-SignedHeaders=content-type%3Bhost&X-Google-Signature=2703915919f8aff425e84f790ad114b81")!
        
var request = URLRequest(url:url)
    
var request.httpMethod="POST"
        
letweetIDs=["1577730467436138524", "1565318587736285184", "1565318587736285184", "1564694842311049217" ]
request.httpBody=tweetIDs.joined(separator:"\n").data(using:.utf8)!
    
let(responseData,_) = try away URLSession.shared.data(for:request)

print(String(data:responseData, encoding: .utf8)!)
<?xml version='1.0' encoding='UTF-8'?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided.
Check your Google secret key and signing method.
</Message>
<StringToSign>
GOOG4-RSA-SHA256
20221009T131424Z
20221009/auto/storage/goog4_request
5c45ee0335cfb583f650af1d68f9fb10b2f72e34aed04a5ca8ad22942a537020
</StringToSign>
<CanonicalRequest>
POST
/twttr-tweet-component/1579097950700961793/submission/1468034183536984067_1579097950700961793
X-Google-Algorism=GOOG4-RSA-SHA256&X-Google-Credential= compliance-public-svc-acct%40twttr-compliance-public-prod.iam.gserviceaccount.com%2F 20221009%2Fauto%2FStorage%2FGoogle4_request&X-Google-Date=20221009Tvc-acct% %;900p;Expire=
content-type —application/x-www-form-urlencoded
host: storage.googleapis.com

content-type;host
UNSIGNED-PAYLOAD
</CanonicalRequest>
</Error>

swift twitter

2022-10-10 01:00

1 Answers

It wasn't "POST" but "PUT"


2022-10-10 01:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.