में Google कस्टम खोज API का उपयोग करने के लिए चरण मैं अपने .NET प्रोजेक्ट में Google कस्टम खोज API का उपयोग करने का प्रयास कर रहा हूं। मेरे पास मेरी कंपनी द्वारा प्रदान की गई एक एपीआई कुंजी है। मैंने अपने Google खाते का उपयोग करके कस्टम खोज इंजन बनाया है और 'cx' मान कॉपी किया है।.NET
string apiKey = "My company Key";
string cx = "Cx";
string query = tbSearch.Text;
WebClient webClient = new WebClient();
webClient.Headers.Add("user-agent", "Only a test!");
string result = webClient.DownloadString(String.Format("https://www.googleapis.com/customsearch/v1?key={0}&cx={1}&q={2}&alt=json", apiKey, cx, query));
मैं निम्न त्रुटि हो रही है:
मैं निम्नलिखित कोड का उपयोग कर रहा
मैं भी निम्न कोड की कोशिश की है: "। (403) निषिद्ध दूरस्थ सर्वर ने एक त्रुटि दी" :
Google.Apis.Customsearch.v1.CustomsearchService svc = new Google.Apis.Customsearch.v1.CustomsearchService();
svc.Key = apiKey;
Google.Apis.Customsearch.v1.CseResource.ListRequest listRequest = svc.Cse.List(query);
listRequest.Cx = cx;
Google.Apis.Customsearch.v1.Data.Search search = listRequest.Fetch();
foreach (Google.Apis.Customsearch.v1.Data.Result result1 in search.Items)
{
Console.WriteLine("Title: {0}", result1.Title);
Console.WriteLine("Link: {0}", result1.Link);
}
यहाँ मैं निम्न अपवाद पर (लायें) मिलती है:
Google.Apis.Requests.RequestError पहुँच कॉन्फ़िगर नहीं किया गया [403] त्रुटियां [संदेश [पहुंच कॉन्फ़िगर नहीं किया गया] स्थान [-] कारण [accessNotConfigured] डोमेन [usageLimits]
CX पैरामीटर की आवश्यकता है? क्या मुझे त्रुटि मिल रही है क्योंकि मैं अपनी कंपनी द्वारा प्रदान की गई कुंजी का उपयोग कर रहा हूं और कस्टम खोज इंजन से अपने Google खाते का उपयोग कर सीएक्स पैरामीटर का उपयोग कर रहा हूं?
क्या 'सीएक्स' पाने का कोई और तरीका है? हम Google एडी प्रदर्शित नहीं करना चाहते हैं।
सहायता के लिए अग्रिम धन्यवाद।
देखें http://hintdesk.com/c-how-to-use-google-custom-search-api/ – Cel