Example #1
0
 /**
  * Performs the update
  *
  * @param RequestInterface $request
  *
  * @return ResponseInterface
  * @throws \RuntimeException When ipv6 address is given
  * @throws \RuntimeException When no ipv4 address is passed
  */
 public function update(RequestInterface $request)
 {
     if (null === $request->getIPv4()) {
         throw new \RuntimeException('You have to pass an ipv4 address');
     }
     if ($request->getIPv6()) {
         throw new \RuntimeException('Cannot use ipv6 with dyn.com provider');
     }
     $url = sprintf('https://%s:%s@members.dyndns.org/nic/update?hostname=%s&myip=%s&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG', $this->user, $this->password, $request->getHost(), $request->getIPv4());
     $curl = curl_init($url);
     curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERAGENT => 'PHP-DynDNS - Library - 1.0'));
     $response = curl_exec($curl);
     curl_close($curl);
     if (false !== strpos($response, 'good')) {
         return new Response(true, $response);
     } else {
         return new Response(false, $response);
     }
 }