Note that there are some explanatory texts on larger screens.

plurals
  1. POBase64 API Signature in iOS
    primarykey
    data
    text
    <p>For Single Platform Integration i need to create a Base64 Signature <a href="https://singleplatform.jira.com/wiki/display/PubDocs/SinglePlatform+Publisher+Integration#SinglePlatformPublisherIntegration-BuildingValidURLs" rel="nofollow">https://singleplatform.jira.com/wiki/display/PubDocs/SinglePlatform+Publisher+Integration#SinglePlatformPublisherIntegration-BuildingValidURLs</a></p> <p>here is ruby script to create Base64 Signature, which work now i want to create it in iOS.</p> <pre><code>require 'hmac-sha1' require 'base64' def make_signature(uri_path, params, client_id, secret) padding_factor = (4 - secret.length % 4) % 4 secret += "=" * padding_factor secret = secret.gsub(/[-_]/, {"-" =&gt; "+", "_" =&gt; "/"}) binary_key = Base64.decode64(secret) params.update({"client" =&gt; client_id}) path = uri_path + "?" + params.collect{|k,v| "#{k}=#{v}"}.inject{|initial,cur| initial + "&amp;" + cur} digest = HMAC::SHA1.new(binary_key).update(path).digest digest = Base64.encode64(digest).gsub(/[+\/]/, {"+" =&gt; "-", "/" =&gt; "_"}).delete("=") return "#{path}&amp;sig=#{digest}" end puts 'http://api.singleplatform.co' + make_signature('/locations/haru-7', {}, "YOUR CLIENT ID", "YOUR SECRET") </code></pre> <h3>What I have tried</h3> <p>I have tried <a href="https://github.com/MealCatcher/objc-singleplatform" rel="nofollow">https://github.com/MealCatcher/objc-singleplatform</a> it not working. I have also tried Base64 &amp; iOS 7 CommonHMAC.h framework.</p> <pre><code>//To HMAC-SHA1 Signing static NSData *HMAC_SHA1(NSString *data, NSString *key) { unsigned char buf[CC_SHA1_DIGEST_LENGTH]; CCHmac(kCCHmacAlgSHA1, [key UTF8String], [key length], [data UTF8String], [data length], buf); return [NSData dataWithBytes:buf length:CC_SHA1_DIGEST_LENGTH]; } //To Retrieve your private key For URL NSString *uri_path = [NSString stringWithFormat:@"%@?client=%@",@"/locations/haru-7",@"clientID"]; NSMutableString *secret = [NSMutableString stringWithFormat:@"%@=",signingKey]; [secret stringByReplacingOccurrencesOfString:@"-" withString:@"+"]; [secret stringByReplacingOccurrencesOfString:@"_" withString:@"/"]; NSData *signature = HMAC_SHA1(uri_path, [secret base64DecodedString]); NSString *base64Signature = [signature base64EncodedString]; [base64Signature stringByReplacingOccurrencesOfString:@"+" withString:@"-"]; [base64Signature stringByReplacingOccurrencesOfString:@"/" withString:@"_"]; </code></pre> <p>Thanks in advance.</p> <p><strong>Full Solution:</strong></p> <p><a href="https://github.com/ronakjangir47/SinglePlatformSignature" rel="nofollow">https://github.com/ronakjangir47/SinglePlatformSignature</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload