v2.5.2
Giriş yap

Wikipedia verilerini PHP ile çekmek ve echo ile göstermek

erdal42
554 defa görüntülendi ve 1 kişi tarafından değerlendirildi

Merhabalar
Wikipedia : https://www.mediawiki.org/wiki/API:Main_page
Bu api ile nasıl php ile çekerim. Resimli ve başlıklı almak istiyorum.
Nasıl yaparız ?

etukenmez
1057 gün önce
$searchParam = htmlspecialchars($_GET['q']);

...

Şeklinde düzenleyebilirsiniz.
Diğer soruların için sanırım gönderilen parametreleri değiştirmek gerekiyor. Tam olarak nasıl çalıştığını anlamak için dökümanlarını okumak gerekiyor.

$searchTitle = [
	"action"=> "query",
	"format"=> "json",
	"prop"=> "imageinfo|images|info|links|categories|description",
	"list"=> "search",
	"titles"=> $searchParam,
	"srsearch"=> $searchParam
]

Bu parametlerelerle gönderildiğinde şöyle bir response geliyor.

{
    "continue": {
        "sroffset": 10,
        "plcontinue": "11089416|0|Test_match_(rugby_union)",
        "continue": "||imageinfo|images|info|categories|description"
    },
    "query": {
        "pages": {
            "11089416": {
                "pageid": 11089416,
                "ns": 0,
                "title": "Test",
                "images": [
                    {
                        "ns": 6,
                        "title": "File:Disambig gray.svg"
                    },
                    {
                        "ns": 6,
                        "title": "File:Semi-protection-shackle.svg"
                    },
                    {
                        "ns": 6,
                        "title": "File:Vector search icon.svg"
                    },
                    {
                        "ns": 6,
                        "title": "File:Wiktionary-logo-en-v2.svg"
                    }
                ],
                "contentmodel": "wikitext",
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr",
                "touched": "2021-12-10T17:03:27Z",
                "lastrevid": 1024744141,
                "length": 2608,
                "links": [
                    {
                        "ns": 0,
                        "title": "Test (Unix)"
                    },
                    {
                        "ns": 0,
                        "title": "Test (assessment)"
                    },
                    {
                        "ns": 0,
                        "title": "Test (biology)"
                    },
                    {
                        "ns": 0,
                        "title": "Test (greyhound competition)"
                    },
                    {
                        "ns": 0,
                        "title": "Test (group)"
                    },
                    {
                        "ns": 0,
                        "title": "Test (law)"
                    },
                    {
                        "ns": 0,
                        "title": "Test (wrestler)"
                    },
                    {
                        "ns": 0,
                        "title": "Test cricket"
                    },
                    {
                        "ns": 0,
                        "title": "Test equipment"
                    },
                    {
                        "ns": 0,
                        "title": "Test match (rugby league)"
                    }
                ],
                "categories": [
                    {
                        "ns": 14,
                        "title": "Category:All article disambiguation pages"
                    },
                    {
                        "ns": 14,
                        "title": "Category:All disambiguation pages"
                    },
                    {
                        "ns": 14,
                        "title": "Category:Disambiguation pages"
                    },
                    {
                        "ns": 14,
                        "title": "Category:Disambiguation pages with short descriptions"
                    },
                    {
                        "ns": 14,
                        "title": "Category:Disambiguation pages with surname-holder lists"
                    },
                    {
                        "ns": 14,
                        "title": "Category:Short description is different from Wikidata"
                    },
                    {
                        "ns": 14,
                        "title": "Category:Wikipedia indefinitely move-protected pages"
                    },
                    {
                        "ns": 14,
                        "title": "Category:Wikipedia pages semi-protected against vandalism"
                    }
                ],
                "description": "Topics referred to by the same term",
                "descriptionsource": "local"
            }
        },
        "searchinfo": {
            "totalhits": 282902,
            "suggestion": "text",
            "suggestionsnippet": "text"
        },
        "search": [
            {
                "ns": 0,
                "title": "Test",
                "pageid": 11089416,
                "size": 2608,
                "wordcount": 264,
                "snippet": "<span class=\"searchmatch\">Test</span>(s), <span class=\"searchmatch\">testing</span>, or <span class=\"searchmatch\">TEST</span> may refer to: <span class=\"searchmatch\">Test</span> (assessment), an educational assessment intended to measure the respondents' knowledge or other abilities",
                "timestamp": "2021-05-23T21:53:34Z"
            },
            {
                "ns": 0,
                "title": "TeST Gliders",
                "pageid": 24884283,
                "size": 2602,
                "wordcount": 164,
                "snippet": "<span class=\"searchmatch\">TeST</span> Gliders is a manufacturer of ultralight sailplanes and motorgliders based in Brno, Czech Republic. <span class=\"searchmatch\">TeST</span> TST-1 Alpin <span class=\"searchmatch\">TeST</span> TST-3 Alpin T <span class=\"searchmatch\">TeST</span> TST-5",
                "timestamp": "2018-02-22T16:19:10Z"
            },
            {
                "ns": 0,
                "title": ".test",
                "pageid": 2249147,
                "size": 2470,
                "wordcount": 246,
                "snippet": "The name <span class=\"searchmatch\">test</span> is a top-level domain (TLD) that is intended for use in the <span class=\"searchmatch\">testing</span> of software. The name was reserved by the Internet Engineering Task Force",
                "timestamp": "2021-12-24T22:05:27Z"
            },
            {
                "ns": 0,
                "title": "Software testing",
                "pageid": 29090,
                "size": 94953,
                "wordcount": 11447,
                "snippet": "Software <span class=\"searchmatch\">testing</span> is the act of examining the artifacts and the behavior of the software under <span class=\"searchmatch\">test</span> by validation and verification. Software <span class=\"searchmatch\">testing</span> can also",
                "timestamp": "2021-12-29T20:28:18Z"
            },
            {
                "ns": 0,
                "title": "This Is Not a Test!",
                "pageid": 1858823,
                "size": 19480,
                "wordcount": 1300,
                "snippet": "This Is Not a <span class=\"searchmatch\">Test</span>! is the fifth studio album by American rapper Missy Elliott, released by The Goldmind Inc. and Elektra Records on November 25, 2003",
                "timestamp": "2021-12-08T23:57:20Z"
            },
            {
                "ns": 0,
                "title": "COVID-19 testing",
                "pageid": 63204759,
                "size": 178054,
                "wordcount": 20226,
                "snippet": "COVID-19 <span class=\"searchmatch\">testing</span> involves analyzing samples to assess the current or past presence of SARS-CoV-2. The two main branches detect either the presence of",
                "timestamp": "2021-12-30T11:30:31Z"
            },
            {
                "ns": 0,
                "title": "This is a test",
                "pageid": 5069303,
                "size": 240,
                "wordcount": 56,
                "snippet": "This is a <span class=\"searchmatch\">test</span> may refer to: The <span class=\"searchmatch\">testing</span> of the Emergency Alert System The <span class=\"searchmatch\">testing</span> of the former Emergency Broadcast System This disambiguation page lists",
                "timestamp": "2021-11-26T17:39:12Z"
            },
            {
                "ns": 0,
                "title": "The Test",
                "pageid": 23262214,
                "size": 1389,
                "wordcount": 180,
                "snippet": "The <span class=\"searchmatch\">Test</span> may refer to: &quot;The <span class=\"searchmatch\">Test</span>&quot; (short story), short story by Franz Kafka The <span class=\"searchmatch\">Test</span> (Wright novel), novel by Mary Tappan Wright The <span class=\"searchmatch\">Test</span> (Applegate novel)",
                "timestamp": "2020-04-04T23:45:04Z"
            },
            {
                "ns": 0,
                "title": "Bechdel test",
                "pageid": 32255505,
                "size": 62268,
                "wordcount": 6092,
                "snippet": "The Bechdel <span class=\"searchmatch\">test</span> (/\u02c8b\u025bkd\u0259l/ BEK-d\u0259l) is a measure of the representation of women in fiction. It asks whether a work features at least two women who talk",
                "timestamp": "2021-12-31T04:57:17Z"
            },
            {
                "ns": 0,
                "title": "Test cricket",
                "pageid": 30863,
                "size": 39657,
                "wordcount": 4028,
                "snippet": "<span class=\"searchmatch\">Test</span> cricket is the form of the sport of cricket with the longest match duration and is considered the game's highest standard. Rotary <span class=\"searchmatch\">Test</span> matches are",
                "timestamp": "2021-12-30T14:00:33Z"
            }
        ]
    }
}

buradaki değerlere inceleyip işine yarayanları kullabilirsin.
Kendisinin yayınlamış olduğu bir APISandBox mevcur burayı incelemeni tavsiye ederim çokça açıklama var kurcalayarak istediğin sonucu elde edebileceğini düşünüyorum.