從你使用的$ _GET,我假設你正在談論PHP。不幸的是,散列標籤永遠不會發送到服務器。他們只生活在客戶端,所以你需要使用一些JavaScript來調用PHP腳本。
例子:
<script type="text/javascript">
var HashSearch = new function() {
var params;
this.set = function (key, value) {
params[key] = value;
this.push();
};
this.remove = function (key, value) {
delete params[key];
this.push();
};
this.get = function (key, value) {
return params[key];
};
this.keyExists = function (key) {
return params.hasOwnProperty(key);
};
this.push= function() {
var hashBuilder = [], key, value;
for(key in params) if (params.hasOwnProperty(key)) {
key = escape(key), value = escape(params[key]); // escape(undefined) == "undefined"
hashBuilder.push(key + ((value !== "undefined") ? '=' + value : ""));
}
window.location.hash = hashBuilder.join("&");
};
(this.load = function() {
params = {}
var hashStr = window.location.hash, hashArray, keyVal
hashStr = hashStr.substring(1, hashStr.length);
hashArray = hashStr.split('&');
for(var i = 0; i < hashArray.length; i++) {
keyVal = hashArray[i].split('=');
params[unescape(keyVal[0])] = (typeof keyVal[1] != "undefined") ? unescape(keyVal[1]) : keyVal[1];
}
})();
}
$.ajax({
type: "POST",
url: '/store_access.php',
data: 'access_token='+escape(HashSearch.get('access_token'),
dataType: "html",
success: function(response) {
alert('Access Token Stored');
}
});
</script>
我在這裏找到了HashSearch功能:Retrieve specific hash tag's value from url
另外,我認爲在張貼到您的腳本jQuery的,但你可以用什麼來撥打電話。您甚至可以使用包含令牌的網址將圖片添加到正文中。