lightopenid - PHP | preg_match(): Unknown modifier '(' in C:\xampp\htdocs\Folder\index.php on line 38 -
i'm trying let people log in steam, using code:
<?php require './includes/lightopenid/openid.php'; $_steamapi = "mykey"; try { $openid = new lightopenid('localhost'); if(!$openid->mode) { if(isset($_get['login'])) { $openid->identity = 'http://steamcommunity.com/openid/?l=english'; header('location: ' . $openid->authurl()); } else { echo "<h2>connect steam</h2>"; echo "<form action='?login' method='post'>"; echo "<input type='image' src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png'>"; echo "</form>"; } } elseif($openid->mode == 'cancel') { echo 'user has canceled authentication!'; } else { if($openid->validate()) { echo "user logged in.\n"; $id = $openid->identity; $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id/(7[0-9]{15,25}+)$/"; preg_match($ptn, $id, $matches); $url = "http://api.steampowered.com/isteamuser/getplayersummaries/v0002/?key=$_steamapi&steamids=$matches[1]"; $json_object= file_get_contents($url); $json_decoded = json_decode($json_object); foreach ($json_decoded->response->players $player) { } } else { echo "user not logged in.\n"; } } } catch(errorexception $e) { echo $e->getmessage(); } ?>
i error:
php | preg_match(): unknown modifier '(' in c:\xampp\htdocs\folder\index.php on line 38
i can't find issue! know where problem is, can't find wrong i've done. what's cause, , how fix it?
you forgot 1 "\" before "/)" on pattern :
$ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
so php thinking "/(" modifier : http://php.net/manual/sr/reference.pcre.pattern.modifiers.php
Comments
Post a Comment