Home Game Development Hello, I’m having an issue making an attempt to community php from server however I do not assume the code is unsuitable are you keen to assist me? – C++

Hello, I’m having an issue making an attempt to community php from server however I do not assume the code is unsuitable are you keen to assist me? – C++

0
Hello, I’m having an issue making an attempt to community php from server however I do not assume the code is unsuitable are you keen to assist me? – C++

[ad_1]

Hello, I’m having an issue making an attempt to community php from server however I don’t assume the code is unsuitable are you keen to assist me?

that is my code

cocos2d::community::HttpRequest* request = new cocos2d::community::HttpRequest();
request->setUrl( “https://www.doniwahyudi.ga/get.php” );
request->setRequestType(cocos2d::community::HttpRequest::Type::GET);
request->setResponseCallback(CC_CALLBACK_2(HelloWorld::onHttpRequestCompleted, this));
request->setTag(“GET test”);
cocos2d::community::HttpClient::getInstance()->ship(request);
request->launch();

void HelloWorld::onHttpRequestCompleted(cocos2d::community::HttpClient* sender, cocos2d::community::HttpResponse* response)
{

// The knowledge might be positioned within the buffer.
std::vector<char>* buffer = response->getResponseInformation();
char* concatenated = (char*)malloc(buffer->dimension() + 1);
std::string s2(buffer->start(), buffer->finish());
strcpy(concatenated, s2.c_str());

// JSON Parser
Json* json = Json_create(concatenated);

int test1 = Json_getInt(json, "a", -1);

const char* test2 = Json_getString(json, "b", "default");

float test3 = Json_getFloat(json, "c", -1.0f);

// View the console
log("HTTP Response : key a : %i", test1);
log("HTTP Response : key b : %s", test2);
log("HTTP Response : key c : %f", test3);

// Delete the JSON object
Json_dispose(json);

if (response->getResponseCode() == 200)
{
    log("Succeeded");

    return;
}
else
{
    log("Failed");
}

}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here