In Django URL patterns, what's the proper way to take this URL:
http://example/i/fb/#access_token=12345678910|b1827b912847b81938747b91849-193867192305817|EKWOGJhcinWIjWij8174-NgjRojb&expires_in=0
And create variables:
access_token = 12345678910|b1827b912847b81938747b91849开发者_如何学C-193867192305817|EKWOGJhcinWIjWij8174-NgjRojb
expires_in = 0
I've been trying to get this to work, but to no avail...
url(r'^fb/(?P([^&]+)(?:&expires=(.*))?/?$, 'app.views.test_url', name="test_url"),
Try this:
'[#?&]?([a-z_]+)=([0-9A-Za-z|\-]+)'
Example application in PHP:
<?php
$url = "http://example/i/fb/#access_token=12345678910|b1827b912847b81938747b91849-193867192305817|EKWOGJhcinWIjWij8174-NgjRojb&expires_in=0";
preg_match_all("%[#?&]?([a-z_]+)=([0-9A-Za-z|\-]+)%", $url, $matches, PREG_SET_ORDER);
print_r($matches);
?>
精彩评论