So im trying to download a text file and return that file back as an Array but im having troubles since it wants me to refrence my custom function library
UFUNCTION(Blueprintpure, Category = "DanCode")
void HttpRequest(FString Link, FString& File);
and my .cpp , that value I want exported is the one called Downloaded, I want it exported through my HttRequest Fucntion back to me when I recall it in blueprints but it wants a Refrence to this class.
void UCustomblueprintfunctionlibrary::HttpRequest(FString Link, FString& File)
{
FHttpModule * http = &FHttpModule::Get();
TSharedRef<IHttpRequest> Request = http->CreateRequest();
Request->OnProcessRequestComplete().BindUObject(this, &UCustomblueprintfunctionlibrary::OnResponseReceived);
//This is the url on which to process the request
Request->SetURL("file:///C:/Bitnami/wampstack-5.6.30-1/apache2/htdocs/download.php");
Request->SetVerb("GET");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->ProcessRequest();
}
void UCustomblueprintfunctionlibrary::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
//Create a pointer to hold the json serialized data
TSharedPtr<FJsonObject> JsonObject;
//Create a reader pointer to read the json data
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
//Deserialize the json data given Reader and the actual object to deserialize
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
//Get the value of the json object by field name
int32 recievedInt = JsonObject->GetIntegerField("customInt");
//Output it to the engine
FString AbsoluteFilePath = "C:/Users/RG STUDIOS/Desktop/DOWNLOADED.txt";
FString Downloaded = FString::FromInt(recievedInt);
HttpRequest(Downloaded, Downloaded);
}