コード例 #1
0
ファイル: test.go プロジェクト: jfgobin/Gostuff
func main() {
	var s string
	var v url.Values
	s = "Hello "
	s = s + "World"
	v.Add(blob, "yeah")
	fmt.Printf("%s\n", s)
	fmt.Println(v)
}
コード例 #2
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveSelfUser(client oauth2_client.OAuth2Client, m url.Values) (*User, os.Error) {
	resp := new(User)
	if m == nil {
		m = make(url.Values)
	}
	m.Set("include_entities", "true")
	err := retrieveInfo(client, "account/verify_credentials.json", "", m, resp)
	return resp, err
}
コード例 #3
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveUserInfo(client oauth2_client.OAuth2Client, nickName string, m url.Values) (*GetUserInfoResponse, os.Error) {
	resp := new(GetUserInfoResponse)
	if m == nil {
		m = make(url.Values)
	}
	m.Set("NickName", nickName)
	err := retrieveInfo(client, "smugmug.users.getInfo", m, resp)
	return resp, err
}
コード例 #4
0
ファイル: yahoo.go プロジェクト: pombredanne/dsocial.go
func (p *YahooContactService) RetrieveGroups(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Group, NextToken, os.Error) {
	var m url.Values
	m = make(url.Values)
	m.Add("count", "max")
	if next == nil {
	} else if start, ok := next.(int); ok {
		m.Add("start", strconv.Itoa(start))
	}
	resp, err := yahoo.RetrieveCategories(client, m)
	if resp == nil || resp.Categories.Categories == nil || len(resp.Categories.Categories) == 0 || err != nil {
		return make([]*Group, 0), nil, err
	}
	groups := make([]*Group, len(resp.Categories.Categories))
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr os.Error = nil
	for i, yahooGroup := range resp.Categories.Categories {
		var externalGroupId string
		if yahooGroup.Id > 0 {
			externalGroupId = strconv.Itoa64(yahooGroup.Id)
		}
		var origDsocialGroup *dm.Group = nil
		dsocialGroupId := ""
		if len(externalGroupId) > 0 {
			dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
			if err != nil {
				if useErr == nil {
					useErr = err
				}
				continue
			}
			if dsocialGroupId != "" {
				origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
				if err != nil {
					if useErr == nil {
						useErr = err
					}
					continue
				}
			} else {
				ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, &yahooGroup)
			}
		}
		var dsocialGroup *dm.Group = dm.YahooCategoryToDsocial(&yahooGroup, origDsocialGroup, dsocialUserId)
		groups[i] = &Group{
			ExternalServiceId: p.ServiceId(),
			ExternalUserId:    externalUserId,
			ExternalGroupId:   externalGroupId,
			DsocialUserId:     dsocialUserId,
			DsocialGroupId:    dsocialGroupId,
			Value:             dsocialGroup,
		}
	}
	return groups, nil, useErr
}
コード例 #5
0
ファイル: taskqueue.go プロジェクト: ashokgelal/gorilla
// NewPOSTTask creates a Task that will POST to a path with the given form data.
func NewPOSTTask(path string, params url.Values) *Task {
	h := make(http.Header)
	h.Set("Content-Type", "application/x-www-form-urlencoded")
	return &Task{
		Path:    path,
		Payload: []byte(params.Encode()),
		Header:  h,
		Method:  "POST",
	}
}
コード例 #6
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveAlbumInfo(client oauth2_client.OAuth2Client, albumId int64, albumKey string, m url.Values) (*GetAlbumInfoResponse, os.Error) {
	resp := new(GetAlbumInfoResponse)
	if m == nil {
		m = make(url.Values)
	}
	m.Set("AlbumID", strconv.Itoa64(albumId))
	m.Set("AlbumKey", albumKey)
	err := retrieveInfo(client, "smugmug.albums.getInfo", m, resp)
	return resp, err
}
コード例 #7
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveContactSyncForUser(client oauth2_client.OAuth2Client, userId string, revno int64, m url.Values) (*ContactSyncResponse, os.Error) {
	resp := new(ContactSyncResponse)
	if m == nil {
		m = make(url.Values)
	}
	m.Set("view", "sync")
	m.Set("rev", strconv.Itoa64(revno))
	err := retrieveInfo(client, "user", userId, "contacts", "", "", "", m, resp)
	return resp, err
}
コード例 #8
0
ファイル: verify.go プロジェクト: tobi/go-openid
// Like Verify on a parsed URL
func VerifyValues(values url.Values) (grant bool, identifier string, err error) {
	err = nil

	var postArgs url.Values
	postArgs = url.Values(map[string][]string{})

	// Create the url
	URLEndPoint := values.Get("openid.op_endpoint")
	if URLEndPoint == "" {
		log.Printf("no openid.op_endpoint")
		return false, "", errors.New("no openid.op_endpoint")
	}
	for k, v := range values {
		postArgs[k] = v
	}
	postArgs.Set("openid.mode", "check_authentication")
	postContent := postArgs.Encode()

	// Post the request
	var client = new(http.Client)
	postReader := bytes.NewBuffer([]byte(postContent))
	response, err := client.Post(URLEndPoint, "application/x-www-form-urlencoded", postReader)
	if err != nil {
		log.Printf("VerifyValues failed at post")
		return false, "", err
	}

	// Parse the response
	// Convert the reader
	// We limit the size of the response to 1024 bytes but it should be large enough for most cases
	buffer := make([]byte, 1024)
	_, err = response.Body.Read(buffer)
	if err != nil {
		log.Printf("VerifyValues failed reading response")
		return false, "", err
	}

	// Check for ns
	rematch := REVerifyDirectNs.FindSubmatch(buffer)
	if rematch == nil {
		return false, "", errors.New("VerifyValues: ns value not found on the response of the OP")
	}
	nsValue := string(rematch[1])
	if !bytes.Equal([]byte(nsValue), []byte("http://specs.openid.net/auth/2.0")) {
		return false, "", errors.New("VerifyValues: ns value not correct: " + nsValue)
	}

	// Check for is_valid
	match, err := regexp.Match(REVerifyDirectIsValid, buffer)
	if err != nil {
		return false, "", err
	}

	identifier = values.Get("openid.claimed_id")
	if !match {
		log.Printf("no is_valid:true in \"%s\"", buffer)
	}

	return match, identifier, nil
}
コード例 #9
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveAlbums(client oauth2_client.OAuth2Client, heavy bool, m url.Values) (*GetAlbumsResponse, os.Error) {
	resp := new(GetAlbumsResponse)
	if m == nil {
		m = make(url.Values)
	}
	if heavy {
		m.Set("Heavy", "true")
	}
	err := retrieveInfo(client, "smugmug.albums.get", m, resp)
	return resp, err
}
コード例 #10
0
ファイル: server_auth.go プロジェクト: huwenshu/chunkymonkey
// Build a URL+query string based on a given server URL, serverId and user
// input
func (s *ServerAuth) BuildQuery(serverId, user string) (query string) {
	queryValues := url.Values{
		"serverId": {serverId},
		"user":     {user},
	}

	queryUrl := s.baseUrl
	queryUrl.RawQuery = queryValues.Encode()

	return queryUrl.String()
}
コード例 #11
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveProfileImage(client oauth2_client.OAuth2Client, screenName, size string, userId int64, includeEntities bool, m url.Values) (*http.Response, os.Error) {
	uri := TWITTER_API_ENDPOINT + "users/profile_image"
	if m == nil {
		m = make(url.Values)
	}
	if len(screenName) > 0 {
		m.Set("screen_name", screenName)
	} else {
		return nil, os.NewError("Must specify either screenName in twitter.RetrieveProfileImage()")
	}
	resp, _, err := oauth2_client.AuthorizedGetRequest(client, nil, uri, m)
	return resp, err
}
コード例 #12
0
ファイル: yahoo.go プロジェクト: pombredanne/dsocial.go
func (p *YahooContactService) RetrieveContacts(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Contact, NextToken, os.Error) {
	var m url.Values
	m = make(url.Values)
	m.Add("count", "max")
	if next == nil {
	} else if start, ok := next.(int); ok {
		m.Add("start", strconv.Itoa(start))
	}
	resp, err := yahoo.RetrieveContacts(client, m)
	if resp == nil || resp.Contacts.Contacts == nil || len(resp.Contacts.Contacts) == 0 || err != nil {
		return make([]*Contact, 0), nil, err
	}
	contacts := make([]*Contact, len(resp.Contacts.Contacts))
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr os.Error = nil
	for i, yahooContact := range resp.Contacts.Contacts {
		externalContactId := strconv.Itoa64(yahooContact.Id)
		dsocialContactId := ""
		var origDsocialContact *dm.Contact = nil
		if len(externalContactId) > 0 {
			dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, externalContactId)
			if err != nil {
				useErr = err
				continue
			}
			if dsocialContactId != "" {
				origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
				if err != nil {
					useErr = err
					continue
				}
			} else {
				ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, &yahooContact)
			}
		}
		dsocialContact := dm.YahooContactToDsocial(&yahooContact, origDsocialContact, dsocialUserId)
		contacts[i] = &Contact{
			ExternalServiceId: p.ServiceId(),
			ExternalUserId:    externalUserId,
			ExternalContactId: externalContactId,
			DsocialUserId:     dsocialUserId,
			DsocialContactId:  dsocialContactId,
			Value:             dsocialContact,
		}
	}
	return contacts, nil, useErr
}
コード例 #13
0
ファイル: escape.go プロジェクト: pombredanne/dsocial.go
// (2011-06-21) - The standard go http.Values.Escape
// works properly for SQS  and S3, but it should be
// noted that at least SDB requiers more to be escaped
// than is officially standard.
//
// Sorted Escape also sorts the keys before joining them (needed
// for canonicalization).
func SortedEscape(v url.Values) (out string) {
	keys := []string{}
	for k := range v {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for k := range keys {
		if k > 0 {
			out += "&"
		}
		// out += http.URLEscape(keys[k]) + "=" + http.URLEscape(v.Get(keys[k]))
		out += escape(keys[k]) + "=" + escape(v.Get(keys[k]))
	}
	return
}
コード例 #14
0
ファイル: gohub.go プロジェクト: supr/gohub
func (p *PullRequest) NewIssueComment(body string) (*Comment, os.Error) {
	url_ := fmt.Sprintf("%v/repos/%v/%v/issues/%v/comments", p.g.apiHost, p.Head.Repo.Name, p.Head.Repo.Owner.Login, p.Number)
	params := url.Values{}
	params.Add("body", body)
	out, err := p.g.makePostRequest(url_, strings.NewReader(params.Encode()))
	if err != nil {
		return nil, err
	}

	var comment Comment
	err = json.Unmarshal(out, &comment)
	if err != nil {
		return nil, err
	}

	return &comment, nil
}
コード例 #15
0
ファイル: gohub.go プロジェクト: supr/gohub
func (g *GoHub) makeGetRequest(url_ string, params url.Values) ([]byte, os.Error) {
	req, err := g.makeAuthRequest("GET", url_, strings.NewReader(params.Encode()))
	if err != nil {
		return nil, err
	}

	resp, err := g.client.Do(req)
	if err != nil {
		return nil, err
	}

	outbuf, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	return outbuf, err
}
コード例 #16
0
ファイル: oauth.go プロジェクト: ipeet/camlistore
func (t *Transport) updateToken(tok *Token, v url.Values) os.Error {
	v.Set("client_id", t.ClientId)
	v.Set("client_secret", t.ClientSecret)
	r, err := (&http.Client{Transport: t.transport()}).PostForm(t.TokenURL, v)
	if err != nil {
		return err
	}
	defer r.Body.Close()
	if r.StatusCode != 200 {
		return os.NewError("invalid response: " + r.Status)
	}
	if err = json.NewDecoder(r.Body).Decode(tok); err != nil {
		return err
	}
	if tok.TokenExpiry != 0 {
		tok.TokenExpiry = time.Seconds() + tok.TokenExpiry
	}
	return nil
}
コード例 #17
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func retrieveInfo(client oauth2_client.OAuth2Client, scope, userId, projection, id string, m url.Values, value interface{}) (err os.Error) {
	var useUserId string
	if len(userId) <= 0 {
		useUserId = GOOGLE_DEFAULT_USER_ID
	} else {
		useUserId = url.QueryEscape(userId)
	}
	if len(projection) <= 0 {
		projection = GOOGLE_DEFAULT_PROJECTION
	}
	headers := make(http.Header)
	headers.Set("GData-Version", "3.0")
	if m == nil {
		m = make(url.Values)
	}
	if len(m.Get(CONTACTS_ALT_PARAM)) <= 0 {
		m.Set(CONTACTS_ALT_PARAM, "json")
	}
	uri := GOOGLE_FEEDS_API_ENDPOINT
	for _, s := range []string{scope, useUserId, projection, id} {
		if len(s) > 0 {
			if uri[len(uri)-1] != '/' {
				uri += "/"
			}
			uri += s
		}
	}
	resp, _, err := oauth2_client.AuthorizedGetRequest(client, headers, uri, m)
	if err != nil {
		return err
	}
	if resp != nil {
		if resp.StatusCode >= 400 {
			b, _ := ioutil.ReadAll(resp.Body)
			err = os.NewError(string(b))
		} else {
			err = json.NewDecoder(resp.Body).Decode(value)
		}
	}
	return err
}
コード例 #18
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveAlbumStats(client oauth2_client.OAuth2Client, albumId int64, year, month int, heavy bool, m url.Values) (*AlbumStatsResponse, os.Error) {
	resp := new(AlbumStatsResponse)
	if m == nil {
		m = make(url.Values)
	}
	m.Set("AlbumID", strconv.Itoa64(albumId))
	m.Set("Year", strconv.Itoa(year))
	m.Set("Month", strconv.Itoa(month))
	if heavy {
		m.Set("Heavy", "true")
	}
	err := retrieveInfo(client, "smugmug.albums.getStats", m, resp)
	return resp, err
}
コード例 #19
0
ファイル: amzses.go プロジェクト: rsec/amzses
func sesGet(data url.Values) (string, os.Error) {
	data.Add("AWSAccessKeyId", accessKey)
	urlstr := fmt.Sprintf("%s?%s", endpoint, data.Encode())
	endpointURL, _ := url.Parse(urlstr)
	headers := map[string][]string{}

	now := time.UTC()
	date := now.Format("Mon, 02 Jan 2006 15:04:05 -0700")
	headers["Date"] = []string{date}

	h := hmac.NewSHA256([]uint8(secretKey))
	h.Write([]uint8(date))
	signature := base64.StdEncoding.EncodeToString(h.Sum())
	auth := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s", accessKey, signature)
	headers["X-Amzn-Authorization"] = []string{auth}

	req := http.Request{
		URL:        endpointURL,
		Method:     "GET",
		ProtoMajor: 1,
		ProtoMinor: 1,
		Close:      true,
		Header:     headers,
	}

	r, err := http.DefaultClient.Do(&req)
	if err != nil {
		return "", err
	}

	resultbody, _ := ioutil.ReadAll(r.Body)
	r.Body.Close()

	if r.StatusCode != 200 {
		return "", os.NewError(string(resultbody))
	}

	return string(resultbody), nil
}
コード例 #20
0
ファイル: notifo.go プロジェクト: chrisfarms/notifo
// optional params for "options" map are:
//
// label: label describing the "application" (used only if being sent from a User account; the Service label is automatically applied if being sent from a Service account)
// title: name of "notification event
// uri: the uri that will be loaded when the notification is opened; if specified, must be urlencoded; if a web address, must start with http:// or https://
//
func (nc *Client) Send(to string, msg string, options ...M) os.Error {
	data := url.Values{}
	data.Add("to", to)
	data.Add("msg", msg)
	// grab optional parameters
	for _, option := range options {
		for k, v := range option {
			data.Add(k, v)
		}
	}
	_, err := nc.request("/send_notification", data)
	return err
}
コード例 #21
0
ファイル: notifo.go プロジェクト: chrisfarms/notifo
func (nc *Client) request(path string, data url.Values) (*response, os.Error) {
	// endpoint
	url := "https://api.notifo.com/v1" + path
	// encode request params
	reqBody := strings.NewReader(data.Encode())
	// build request
	req, err := http.NewRequest("POST", url, reqBody)
	if err != nil {
		return nil, err
	}
	req.Method = "POST"
	req.SetBasicAuth(nc.Username, nc.ApiSecret)
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	// make request
	client := new(http.Client)
	r, err := client.Do(req)
	// check connection
	if err != nil {
		return nil, err
	}
	defer r.Body.Close()
	// read response
	body, _ := ioutil.ReadAll(r.Body)
	// decode json
	response := new(response)
	err = json.Unmarshal(body, &response)
	if err != nil {
		return nil, err
	}
	// check for success code
	if response.Code != 2201 {
		return nil, fmt.Errorf("notifo: %s", response.Message)
	}
	// no error
	return response, nil
}
コード例 #22
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func retrieveInfo(client oauth2_client.OAuth2Client, method string, m url.Values, value interface{}) (err os.Error) {
	uri := SMUGMUG_API_ENDPOINT
	headers := make(http.Header)
	headers.Set("Accept", "application/json")
	if m == nil {
		m = make(url.Values)
	}
	m.Set("method", method)
	resp, _, err := oauth2_client.AuthorizedGetRequest(client, headers, uri, m)
	if err != nil {
		return err
	}
	if resp != nil {
		var e ErrorResponse
		b, _ := ioutil.ReadAll(resp.Body)
		json.Unmarshal(b, &e)
		if e.Stat != "ok" {
			err = &e
		} else {
			err = json.Unmarshal(b, value)
		}
	}
	return err
}
コード例 #23
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveUser(client oauth2_client.OAuth2Client, screenName string, userId int64, includeEntities bool, m url.Values) (*User, os.Error) {
	resp := new(User)
	if m == nil {
		m = make(url.Values)
	}
	if userId > 0 {
		m.Set("user_id", strconv.Itoa64(userId))
	} else if len(screenName) > 0 {
		m.Set("screen_name", screenName)
	} else {
		return nil, os.NewError("Must specify either userId or screenName in twitter.RetrieveUser()")
	}
	if includeEntities {
		m.Set("include_entities", "true")
	}
	err := retrieveInfo(client, "users/show.json", "", m, resp)
	return resp, err
}
コード例 #24
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveStatus(client oauth2_client.OAuth2Client, id int64, trimUser, includeEntities bool, m url.Values) (*Status, os.Error) {
	resp := new(Status)
	if m == nil {
		m = make(url.Values)
	}
	if id > 0 {
		m.Set("id", strconv.Itoa64(id))
	} else {
		return nil, os.NewError("Must specify either status Id in twitter.RetrieveStatus()")
	}
	if trimUser {
		m.Set("trim_user", "true")
	}
	if includeEntities {
		m.Set("include_entities", "true")
	}
	err := retrieveInfo(client, "statuses/show.json", "", m, resp)
	return resp, err
}
コード例 #25
0
ファイル: google.go プロジェクト: pombredanne/dsocial.go
func (p *GoogleContactService) RetrieveGroups(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Group, NextToken, os.Error) {
	var m url.Values
	if next == nil {
	} else if s, ok := next.(string); ok {
		if s != "" {
			if strings.HasPrefix(s, "https://www.google.com/") {
				uri, err := url.Parse(s)
				if err == nil {
					q, err := url.ParseQuery(uri.RawQuery)
					if err == nil {
						m = q
					}
				}
			}
			if m == nil {
				m = make(url.Values)
				m.Add("q", s)
			}
		}
	} else if maxResults, ok := next.(int); ok {
		m = make(url.Values)
		m.Add("max-results", strconv.Itoa(maxResults))
	} else if maxResults, ok := next.(int64); ok {
		m = make(url.Values)
		m.Add("max-results", strconv.Itoa64(maxResults))
	} else if gq, ok := next.(*google.GroupQuery); ok {
		m = make(url.Values)
		if gq.Alt != "" {
			m.Add("alt", gq.Alt)
		}
		if gq.Q != "" {
			m.Add("q", gq.Q)
		}
		if gq.MaxResults > 0 {
			m.Add("max-results", strconv.Itoa64(gq.MaxResults))
		}
		if gq.StartIndex > 0 {
			m.Add("start-index", strconv.Itoa64(gq.StartIndex))
		}
		if gq.UpdatedMin != "" {
			m.Add("updated-min", gq.UpdatedMin)
		}
		if gq.OrderBy != "" {
			m.Add("orderby", gq.OrderBy)
		}
		if gq.ShowDeleted {
			m.Add("showdeleted", "true")
		}
		if gq.RequireAllDeleted {
			m.Add("requirealldeleted", "true")
		}
		if gq.SortOrder != "" {
			m.Add("sortorder", gq.SortOrder)
		}
	}
	resp, err := google.RetrieveGroups(client, m)
	var theNextToken NextToken = nil
	if resp != nil && resp.Feed != nil && resp.Feed.Links != nil && len(resp.Feed.Links) > 0 {
		for _, link := range resp.Feed.Links {
			if link.Rel == "next" {
				theNextToken = link.Href
			}
		}
	}
	if resp == nil || resp.Feed == nil || resp.Feed.Entries == nil || len(resp.Feed.Entries) == 0 || err != nil {
		return make([]*Group, 0), theNextToken, err
	}
	groups := make([]*Group, len(resp.Feed.Entries))
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr os.Error = nil
	for i, googleGroup := range resp.Feed.Entries {
		externalGroupId := googleGroup.GroupId()
		var origDsocialGroup *dm.Group = nil
		dsocialGroupId := ""
		if len(externalGroupId) > 0 {
			dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
			if err != nil {
				if useErr == nil {
					useErr = err
				}
				continue
			}
			if dsocialGroupId != "" {
				origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
				if err != nil {
					if useErr == nil {
						useErr = err
					}
					continue
				}
			} else {
				ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, &googleGroup)
			}
		}
		var dsocialGroup *dm.Group = dm.GoogleGroupToDsocial(&googleGroup, origDsocialGroup, dsocialUserId)
		groups[i] = &Group{
			ExternalServiceId: p.ServiceId(),
			ExternalUserId:    googleGroup.GroupUserId(),
			ExternalGroupId:   googleGroup.GroupId(),
			DsocialUserId:     dsocialUserId,
			DsocialGroupId:    dsocialGroupId,
			Value:             dsocialGroup,
		}
	}
	return groups, theNextToken, useErr
}
コード例 #26
0
ファイル: client.go プロジェクト: Sunmonds/gcc
// PostForm issues a POST to the specified URL,
// with data's keys and values urlencoded as the request body.
//
// Caller should close r.Body when done reading from it.
func (c *Client) PostForm(url string, data url.Values) (r *Response, err os.Error) {
	return c.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
}
コード例 #27
0
ファイル: notifo.go プロジェクト: chrisfarms/notifo
// Register a client
func (nc *Client) Subscribe(username string) os.Error {
	data := url.Values{}
	data.Add("username", username)
	_, err := nc.request("/subscribe_user", data)
	return err
}
コード例 #28
0
ファイル: service.go プロジェクト: pombredanne/contacts.go
func RetrieveStatusesWithOptions(client oauth2_client.OAuth2Client, screenName string, userId, sinceId, count, maxId, page int64, trimUser, includeRts, includeEntities, excludeReplies, contributorDetails bool, m url.Values) (*[]Status, os.Error) {
	resp := new([]Status)
	if m == nil {
		m = make(url.Values)
	}
	if userId > 0 {
		m.Set("user_id", strconv.Itoa64(userId))
	} else if len(screenName) > 0 {
		m.Set("screen_name", screenName)
	} else {
		return nil, os.NewError("Must specify either userId or screenName in twitter.RetrieveStatus()")
	}
	if sinceId > 0 {
		m.Set("since_id", strconv.Itoa64(sinceId))
	}
	if count > 0 {
		m.Set("count", strconv.Itoa64(count))
	}
	if maxId > 0 {
		m.Set("max_id", strconv.Itoa64(maxId))
	}
	if page > 0 {
		m.Set("page", strconv.Itoa64(page))
	}
	if trimUser {
		m.Set("trim_user", "true")
	}
	if includeRts {
		m.Set("include_rts", "true")
	}
	if includeEntities {
		m.Set("include_entities", "true")
	}
	if excludeReplies {
		m.Set("exclude_replies", "true")
	}
	if contributorDetails {
		m.Set("contributor_details", "true")
	}
	err := retrieveInfo(client, "statuses/user_timeline.json", "", m, resp)
	return resp, err
}