2015-04-04, 05:30 AM
I'm wondering if it's a case of needing a real sid, instead of "plex". My debug builds don't enforce the session security, for my own convenience when testing, but for you in a release build, you may need to have a real session. I'm not 100% sure though, because there is some special case stuff if you're on the local network. If other calls are working, like getting recording lists, then its unlikely to be that. (I'm not sure what other calls you're using)
Here is some example code of a login happening from XBMC:
Here is some example code of a login happening from XBMC:
Code:
bool cPVRClientNextPVR::Connect()
{
string result;
// initiate session
CStdString response;
if (DoRequest("/service?method=session.initiate&ver=1.0&device=xbmc", response) == HTTP_OK)
{
TiXmlDocument doc;
if (doc.Parse(response) != NULL)
{
TiXmlElement* saltNode = doc.RootElement()->FirstChildElement("salt");
TiXmlElement* sidNode = doc.RootElement()->FirstChildElement("sid");
if (saltNode != NULL && sidNode != NULL)
{
// extract and store sid
PVR_STRCPY(m_sid, sidNode->FirstChild()->Value());
// extract salt
char salt[64];
PVR_STRCPY(salt, saltNode->FirstChild()->Value());
// a bit of debug
XBMC->Log(LOG_DEBUG, "session.initiate returns: sid=%s salt=%s", m_sid, salt);
CStdString pinMD5 = PVRXBMC::XBMC_MD5::GetMD5(g_szPin);
pinMD5.ToLower();
// calculate combined MD5
CStdString combinedMD5;
combinedMD5.append(":");
combinedMD5.append(pinMD5);
combinedMD5.append(":");
combinedMD5.append(salt);
// get digest
CStdString md5 = PVRXBMC::XBMC_MD5::GetMD5(combinedMD5);
// login session
CStdString loginResponse;
char request[512];
sprintf(request, "/service?method=session.login&sid=%s&md5=%s", m_sid, md5.c_str());
if (DoRequest(request, loginResponse) == HTTP_OK)
{
if (strstr(loginResponse, "<rsp stat=\"ok\">"))
{
m_bConnected = true;
XBMC->Log(LOG_DEBUG, "session.login successful");
return true;
}
else
{
XBMC->Log(LOG_DEBUG, "session.login failed");
XBMC->QueueNotification(QUEUE_ERROR, XBMC->GetLocalizedString(30052));
m_bConnected = false;
}
}
}
}
}
return false;
}