func (s *Session) jsonForPost(url string, params url.Values) ([]byte, error) {
	return jsonForResp(s.Client.PostForm(url, params))
}
jsonForPost posts the form and returns the raw JSON
from the response.
package fbmsgr
import (
	"context"
	"encoding/json"
	"errors"
	"io/ioutil"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	"time"
	"golang.org/x/net/html"
)
const dtsgTimeout = time.Hour * 8
func (s *Session) fetchDTSG() (string, error) {
	s.fbDTSGLock.Lock()
	defer s.fbDTSGLock.Unlock()
	if s.fbDTSG != "" {
		if time.Since(s.fbDTSGTime) > dtsgTimeout {
			s.fbDTSG = ""
		} else {
			return s.fbDTSG, nil
		}
	}
	homepage, err := s.Client.Get(BaseURL)
	if homepage != nil {
		defer homepage.Body.Close()
	}
	if err != nil {
		return "", errors.New("fetch dtsg: " + err.Error())
	}
	parsed, err := html.Parse(homepage.Body)
	if err != nil {
		return "", errors.New("fetch dtsg: " + err.Error())
	}
	const fieldName = `DTSGInitialData",\[\],{"token`
	keyVal, err := findJSField(parsed, fieldName)
	if err != nil {
		return "", errors.New("fetch dtsg: " + err.Error())
	}
	s.fbDTSG = keyVal
	s.fbDTSGTime = time.Now()
	return s.fbDTSG, nil
}
func (s *Session) commonParams() (url.Values, error) {
	dtsg, err := s.fetchDTSG()
	if err != nil {
		return nil, err
	}
	reqParams := url.Values{}
	reqParams.Add("__a", "1")
	reqParams.Add("__af", "o")
	reqParams.Add("__be", "-1")
	reqParams.Add("__pc", "EXP1:messengerdotcom_pkg")
	reqParams.Add("__req", "14")
	reqParams.Add("__rev", "2643465")
	reqParams.Add("__srp_t", "1477432416")
	reqParams.Add("__user", s.userID)
	reqParams.Add("client", "mercury")
	reqParams.Add("fb_dtsg", dtsg)
	return reqParams, nil
}
func (s *Session) graphQLDoc(docID string, params map[string]interface{},
	dataOut interface{}) error {
	reqParams, err := s.commonParams()
	if err != nil {
		return err
	}
	reqObj := map[string]interface{}{"doc_id": docID, "query_params": params}
	reqJSON, err := json.Marshal(map[string]interface{}{"o0": reqObj})
	if err != nil {
		return err
	}
	reqParams.Add("queries", string(reqJSON))
	resp, err := s.Client.PostForm(BaseURL+"/api/graphqlbatch", reqParams)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	decoder := json.NewDecoder(resp.Body)
	var respObj struct {
		Object struct {
			Data   interface{} `json:"data"`
			Errors []struct {
				Message string `json:"message"`
			} `json:"errors"`
		} `json:"o0"`
		Error struct {
			Message string `json:"description"`
		} `json:"error"`
	}
	respObj.Object.Data = dataOut
	if err := decoder.Decode(&respObj); err != nil {
		return err
	}
	if len(respObj.Object.Errors) > 0 {
		return errors.New("GraphQL error: " + respObj.Object.Errors[0].Message)
	} else if respObj.Error.Message != "" {
		return errors.New("GraphQL error: " + respObj.Error.Message)
	}
	return nil
}