function send($source_url, $target_url) { if ($target_webmention_endpoint = discover($target_url)) { $response_body = http\request("POST {$target_webmention_endpoint}", array(), array('source' => $source_url, 'target' => $target_url), $response_headers); return array('headers' => $response_headers, 'body' => $response_body); } }
function access_token($shop, $api_key, $shared_secret, $code) { try { $response = http\request("POST https://{$shop}/admin/oauth/access_token", array(), array('client_id' => $api_key, 'client_secret' => $shared_secret, 'code' => $code)); } catch (http\CurlException $e) { throw new CurlException($e->getMessage(), $e->getCode(), $e->getRequest()); } catch (http\ResponseException $e) { throw new ApiException($e->getMessage(), $e->getCode(), $e->getRequest(), $e->getResponse()); } return $response['access_token']; }