Providing authentication info via msxml2.ServerXMLHTTP

前端 未结 2 1016
南笙
南笙 2020-12-03 23:11

I am using Classic ASP and trying to use the JustGiving API.

I\'d like to use it to display the total amount raised, and total donations received on my donation page

2条回答
  •  鱼传尺愫
    2020-12-03 23:43

    Apologies for adding to an old post. However this has consistently come up when Googling for help on MailChimp API V3.0 and VBA.

    This is the fix I used:

    ret = objhttp.Open("POST", sURL, False) 
    objhttp.setRequestHeader "Content-Type", "application/json"
    objhttp.setRequestHeader "Accept", "application/json"
    
    'V3 API uses HTTP Basic Authorisation inside an https: wrapper.
    'The standard windows method does not seem to work however the 
    'following hack does.
    'In summary the user name and APIkey are seperated with a Colon: and 
    'base 64 encoded and added to a Http RequestHeader
    
    
    objhttp.setRequestHeader "Authorization", "Basic " & Base64Encode(APIUser & ":" & ApiKey)
    
    objhttp.send (sJson)
    

    You will need to code the Base64Encode function. I grabbed some code from http://pastie.org/1192157 (Ex StackOverflow) and pasted it into a VBA Module.

    Hope it helps.

提交回复
热议问题