Hi Leute ich bin neu hier ![]()
Ich würde gerne wissen wie man eine API gebundene GET abfrage auf seiner Hompage einbindet.
Wird das mit Javascript oder mit PHP gemacht?
ich habe z.B hier einen Code
- <?php
- // You can download this file from here xxxx_RestClient.zip
- require('RestClient.php');
- $api_url = 'https:xy/';
- try {
- // Instead of 'login' and 'password' use your credentials from xy.pi-dashboard
- $client = new RestClient($api_url, null, 'login', 'password');
- } catch (RestClientException $e) {
- echo "\n";
- print "HTTP code: {$e->getHttpCode()}\n";
- print "Error code: {$e->getCode()}\n";
- print "Message: {$e->getMessage()}\n";
- print $e->getTraceAsString();
- echo "\n";
- exit();
- }
- $post_array = array();
- // You can set only one task at a time
- $post_array[] = array(
- "language_code" => "en",
- "location_code" => 2840,
- "keyword" => mb_convert_encoding("albert einstein", "UTF-8")
- );
- try {
- // POST /v3/serp/google/organic/live/regular
- // in addition to 'google' and 'organic' you can also set other search engine and type parameters
- // the full list of possible parameters is available in documentation
- $result = $client->post('/v3/serp/google/organic/live/regular', $post_array);
- print_r($result);
- // do something with post result
- } catch (RestClientException $e) {
- echo "\n";
- print "HTTP code: {$e->getHttpCode()}\n";
- print "Error code: {$e->getCode()}\n";
- print "Message: {$e->getMessage()}\n";
- print $e->getTraceAsString();
- echo "\n";
- }
- $client = null;
- ?>
und dann habe ich noch diese info hier:
ZitatThe above command returns JSON structured like this:
Code
{ "version": "0.1.20200129", "status_code": 20000, "status_message": "Ok.", "time": "12.2397 sec.", "cost": 0.003, "tasks_count": 1, "tasks_error": 0, "tasks": [ { "id": "01301234-1535-0121-0000-9c8e396a59cc", "status_code": 20000, "status_message": "Ok.", "time": "12.1329 sec.", "cost": 0.003, "result_count": 1, "path": [ "v3", "serp", "google", "organic", "live", "regular" ], "data": { "api": "serp", "function": "live", "se": "google", "se_type": "organic", "language_name": "English", "location_name": "United States", "keyword": "flight ticket new york san francisco", "tag": "tag2",
USW!!!
Meine Frage jetzt wie kann ich von diesem Anbieter diese abfrage auf meine Website einbinden? Ist das überhaupt möglich? Und wenn Ja, wie ? PHP/Javascript ?