| Conditions | 2 |
| Paths | 2 |
| Total Lines | 32 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | public function keyAction(Request $request) |
||
| 11 | { |
||
| 12 | $sitename = $request->query->get('sitename'); |
||
| 13 | $siteId = $request->query->get('uuid'); |
||
| 14 | $apiKey = $request->query->get('key'); |
||
| 15 | |||
| 16 | if (!isset($sitename, $siteId, $apiKey)) |
||
| 17 | { |
||
| 18 | throw new Symfony\Component\HttpKernel\Exception\NotFoundHttpException(); |
||
| 19 | } |
||
| 20 | |||
| 21 | $subId = md5($sitename . $siteId); |
||
| 22 | $expiration = strtotime("+1 year"); |
||
| 23 | $key = $this->getParameter('viglink_api_key'); |
||
| 24 | $secretKey = $this->getParameter('viglink_secret_key'); |
||
| 25 | |||
| 26 | $url = ("https://www.viglink.com/users/convertAccount?key=" . $key . "&subId=" . $subId); |
||
| 27 | $signature = hex(hash_hmac('md5', ($url . "-" . $expiration), $secretKey)); |
||
| 28 | |||
| 29 | $queryParams = http_build_query( |
||
| 30 | ['key' => $key, |
||
| 31 | 'subId' => $subId, |
||
| 32 | 'expiration' => $expiration, |
||
| 33 | 'signature' => $signature,] |
||
| 34 | ); |
||
| 35 | |||
| 36 | $url = ('https://www.viglink.com/ursers/convertaccount' . $queryParams); |
||
| 37 | |||
| 38 | $response = new Response($url); |
||
| 39 | |||
| 40 | return $response; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |