2013-05-20 27 views
1

我想實現在disqus單上簽字,但我似乎無法建立連接Disqus單點登錄的問題,我建立一個測試頁面:上,沒有連接製成

<?php 
define('DISQUS_SECRET_KEY', 'mykey'); 
define('DISQUS_PUBLIC_KEY', 'myotherkey'); 

$data = array(
    "username" => "Disqus Test", 
    "url" => "http://disqus.com", 
    "id" => "999", 
    "avatar" => "http://dl.dropbox.com/u/31679327/Screenshots/30v.png", 
    "email" => "[email protected]" 
); 

function dsq_hmacsha1($data, $key) { 
    $blocksize=64; 
    $hashfunc='sha1'; 
    if (strlen($key)>$blocksize) 
    $key=pack('H*', $hashfunc($key)); 
    $key=str_pad($key,$blocksize,chr(0x00)); 
    $ipad=str_repeat(chr(0x36),$blocksize); 
    $opad=str_repeat(chr(0x5c),$blocksize); 
    $hmac = pack('H*',$hashfunc(
    ($key^$opad).pack('H*',$hashfunc(
    ($key^$ipad).$data) 
    ) 
    ) 
    ); 
return bin2hex($hmac); 
} 

$message = base64_encode(json_encode($data)); 
$timestamp = time(); 
$hmac = dsq_hmacsha1($message . ' ' . $timestamp, DISQUS_SECRET_KEY); 
?> 

<!DOCTYPE HTML> 
<html> 
<head> 
<title>Test Site</title> 
</head> 
<body> 

<div id="disqus_thread"></div> 

<script type="text/javascript"> 
var disqus_config = function() { 
this.page.remote_auth_s3 = "<?php echo "$message $hmac $timestamp"; ?>"; 
this.page.api_key = "<?php echo DISQUS_PUBLIC_KEY; ?>"; 
} 

/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ 
var disqus_shortname = 'funkydic'; // required: replace example with your forum shortname 

/* * * DON'T EDIT BELOW THIS LINE * * */ 
(function() { 
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; 
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; 
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); 
})(); 
</script> 
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> 
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a> 

<?php echo "$message $hmac $timestamp"; ?> 
</body> 
</html> 

我解碼有效載荷,它看起來應該是這樣,問題似乎在於連接,即使是所有的東西看起來都像它應該設置的那樣。

任何幫助apriciated

回答

0

它看起來像你的實際代碼是好的,這是幾乎可以肯定無論是應用配置錯誤或不當,將JavaScript變量。

第一步是看看這個文件,它越過了最常見的問題:http://help.disqus.com/customer/portal/articles/1148640

特別檢查,以確保在X-Disqus-遠程驗證頭使得它在該請求。

如果所有這些檢查出來,發佈頁面的完整源代碼,包括您的公鑰(它只適用於您指定的域),我們可以看看是否有其他錯誤