Sample code for 30+ languages & platforms
Visual FoxPro

Google Search Console API - Delete

See more Google Search Console Examples

Demonstrates how to remove a site from the set of the user's Search Console sites.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loJsonToken
LOCAL loHttp
LOCAL loSbUrlToDelete
LOCAL loSbUrl
LOCAL lcUrl
LOCAL loResp
LOCAL lnStatusCode

lnSuccess = 0

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* This example uses a previously obtained access token having permission for the 
* Google Search Console scope.

* In this example, Get a Google Search Console OAuth2 Access Token, the access
* token was saved to a JSON file.  This example fetches the access token from the file..
loJsonToken = CreateObject('Chilkat.JsonObject')
lnSuccess = loJsonToken.LoadFile("qa_data/tokens/googleSearchConsole.json")
IF (loJsonToken.HasMember("access_token") = 0) THEN
    ? "No access token found."
    RELEASE loJsonToken
    CANCEL
ENDIF

loHttp = CreateObject('Chilkat.Http')
loHttp.AuthToken = loJsonToken.StringOf("access_token")

loSbUrlToDelete = CreateObject('Chilkat.StringBuilder')
loSbUrlToDelete.Append("https://www.example.com/")
loSbUrlToDelete.Encode("url","utf-8")

loSbUrl = CreateObject('Chilkat.StringBuilder')
loSbUrl.Append("https://www.googleapis.com/webmasters/v3/sites/")
loSbUrl.AppendSb(loSbUrlToDelete)

* Our URL looks like this:  https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fwww.example.com%2F
? loSbUrl.GetAsString()

lcUrl = loSbUrl.GetAsString()
loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpNoBody("DELETE",lcUrl,loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loJsonToken
    RELEASE loHttp
    RELEASE loSbUrlToDelete
    RELEASE loSbUrl
    RELEASE loResp
    CANCEL
ENDIF

lnStatusCode = loResp.StatusCode
? "Response Status Code: " + STR(lnStatusCode)

IF (lnStatusCode >= 400) THEN
    ? loResp.BodyStr
    ? "Failed."
ENDIF

RELEASE loJsonToken
RELEASE loHttp
RELEASE loSbUrlToDelete
RELEASE loSbUrl
RELEASE loResp