MeetMax API Request

public class MeetMaxAPI { public static void makeRequest(String urlRequest) { String[] urlParts; if(urlRequest != null && urlRequest != '') { urlParts = urlRequest.split('\\?'); } String urlPath = urlParts[0]; String httpMethod = 'GET'; String serviceUrl = 'http://staging.meetmax.com'+ urlPath; String consumeKey = 'xxxx'; String jsonParam = 'data_type=json'; String otherParams = urlParts.size()==2?urlParts[1]:''; String realPath = jsonParam+(otherParams!=''?('&'+otherParams+'&'):''); String actualEndpoint = serviceUrl+'?'+realPath; String consumeSecret = 'yyyy'; String sigMethod = 'HMAC-SHA1'; String oauthVer = '1.0'; String timeStamp = String.valueOf(System.now().getTime()); String nonce = String.valueOf(Integer.valueOf(10000000/Math.random())); System.debug(LoggingLevel.ERROR,serviceUrl); System.debug(LoggingLevel.ERROR,realPath); String[] baseStrArry = new String[]{httpMethod, EncodingUtil.urlEncode(serviceUrl,'UTF-8'), EncodingUtil.urlEncode(realPath+'&'+ ('oauth_consumer_key='+consumeKey)+'&'+ ('oauth_nonce='+nonce)+'&'+ ('oauth_signature_method='+sigMethod)+'&'+ ('oauth_timestamp='+timeStamp)+'&'+ ('oauth_version='+oauthVer),'UTF-8')}; String baseStr = String.join(baseStrArry,'&'); System.debug(LoggingLevel.ERROR,baseStr); String salt = baseStr; String key = consumeSecret+'&'; Blob data = crypto.generateMac('hmacSHA1',Blob.valueOf(salt), Blob.valueOf(key)); String encSig = EncodingUtil.base64Encode(data); System.debug(LoggingLevel.ERROR,encSig); Http h = new Http(); HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setEndpoint(actualEndpoint); System.debug(LoggingLevel.ERROR,(actualEndpoint)); String[] headSecStrArry = new String[]{('oauth_consumer_key="'+consumeKey+'"'), ('oauth_signature_method="'+sigMethod+'"'), ('oauth_signature="'+EncodingUtil.urlEncode(encSig,'UTF-8')+'"'), ('oauth_timestamp="'+timeStamp+'"'), ('oauth_nonce="'+nonce+'"'), ('oauth_version="'+oauthVer+'"')}; String headSecStr = String.join(headSecStrArry,','); req.setHeader('Authorization','OAuth '+headSecStr); HttpResponse res = h.send(req); System.debug(LoggingLevel.ERROR,res.getBody()); } }
To Create a MeetMax Request in Apex

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.