Demetrio.pepi 0 Newbie Poster

Hello. My whole code is bellow and I getting the error message: {"responseData": null, "responseDetails": "Suspected Terms of Service Abuse. Please see http://code.google.com/apis/errors", "responseStatus": 403}. Do you have some suggestion?

#include <fstream>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include "/usr/include/curl/curl.h"
#include "/usr/include/curl/easy.h"

size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
    size_t written;
    written = fwrite(ptr, size, nmemb, stream);
    return written;
}

int main() {

	CURL *curl;		/* That is the connection, see: curl_easy_init */
	CURLcode res;		/* Not needed, see: curl_easy_cleanup */

	curl = curl_easy_init();
	FILE * fp;
	if(curl) {
		fp = fopen("C:\\trans.txt","wb");
		curl_easy_setopt(curl, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=hello&langpair=en|fr");
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
		fclose(fp);
	}
	fp = fopen("C:\\trans.txt","rb");
	fseek (fp , 0 , SEEK_END);
	long lSize = ftell (fp);
	rewind (fp);

	char *translated;
	translated =(char *)malloc(lSize);
	fread(translated,1,lSize,fp);
	translated[lSize] = 0;
	fclose(fp);
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.