양식에 게시하려면 먼저 게시되는 양식의 URL을 가져와야 합니다. 이렇게 하려면 다음과 같은 웹페이지 소스를 보고 HTML 형식을 얻으세요.
<form action="http://www.example.com/login.php" method="post"> <div class="FormRow"> <label>Username</label> <input type="text" name="username" data-gt-translate-attributes='[{"attribute":"value","format":"json"}]' value=""> </div> <div class="FormRow"> <label>Password</label> <input type="password" name="password" data-gt-translate-attributes='[{"attribute":"value","format":"json"}]' value=""> </div> <input type="submit" class="submit" data-gt-translate-attributes='[{"attribute":"value","format":"json"}]' value="Login"> </form>
양식의 URL이 있으면 대상 웹사이트에서 게시물이 거부되지 않도록 각 양식 입력의 이름과 값을 지정해야 합니다. 이에 대한 예가 아래에 나와 있습니다.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.AddPostParameter("username", "bob"); options.AddPostParameter("password", "pass"); grabzIt.URLToImage("http://www.example.com/login.php", options); grabzIt.Save("http://www.mywebsite.com/handler.ashx");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.AddPostParameter("username", "bob"); options.AddPostParameter("password", "pass"); grabzIt.URLToImage("http://www.example.com/login.php", options); grabzIt.Save("http://www.mywebsite.com/handler");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.5.2/grabzit.min.js"></script> <script> GrabzIt("Sign in to view your Application Key").AddPostVariable("username", "bob").AddPostVariable("password", "pass") .ConvertURL("http://www.example.com/login.php").Create(); </script>
node.js에서 게시물 데이터를 지정할 때 각 게시물 변수의 이름과 값을 URL로 인코딩해야 합니다.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.url_to_image("http://www.example.com/login.php", {"postData":"username=bob&password=pass"}); client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $options = GrabzItImageOptions->new(); $options->AddPostParameter("username", "bob"); $options->AddPostParameter("password", "pass"); $grabzIt->URLToImage("http://www.example.com/login.php", $options); $grabzIt->Save("http://www.mywebsite.com/handler.pl");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); $options = new \GrabzIt\GrabzItImageOptions(); $options->AddPostParameter("username", "bob"); $options->AddPostParameter("password", "pass"); $grabzIt->URLToImage("http://www.example.com/login.php", $options); $grabzIt->Save("http://www.mywebsite.com/handler.php");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItImageOptions.GrabzItImageOptions() options.AddPostParameter("username", "bob"); options.AddPostParameter("password", "pass"); grabzIt.URLToImage("http://www.example.com/login.php", options) grabzIt.Save("http://www.mywebsite.com/handler.py")
요청할 때 기억하세요. 모든 매개변수 값은 URL로 인코딩됩니다. 각 POST 이름과 값도 먼저 URL로 인코딩되어야 합니다.
https://api.grabz.it/services/convert?key=Sign in to view your Application Key&post=username%3Dbob%26password%3Dpass&format=jpg&url=http%3A%2F%2Fwww.example.com%2Flogin.php
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzIt::ImageOptions.new() options.add_post_parameter("username", "bob"); options.add_post_parameter("password", "pass"); grabzIt.url_to_image("http://www.example.com/login.php", options) grabzIt.save("http://www.mywebsite.com/handler/index")