当前位置: 首页>>代码示例>>Golang>>正文


Golang url.Values类代码示例

本文整理汇总了Golang中url.Values的典型用法代码示例。如果您正苦于以下问题:Golang Values类的具体用法?Golang Values怎么用?Golang Values使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Values类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

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)
}
开发者ID:jfgobin,项目名称:Gostuff,代码行数:9,代码来源:test.go

示例2: RetrieveSelfUser

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
}
开发者ID:pombredanne,项目名称:contacts.go,代码行数:9,代码来源:service.go

示例3: RetrieveUserInfo

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
}
开发者ID:pombredanne,项目名称:contacts.go,代码行数:9,代码来源:service.go

示例4: RetrieveGroups

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
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:56,代码来源:yahoo.go

示例5: NewPOSTTask

// 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",
	}
}
开发者ID:ashokgelal,项目名称:gorilla,代码行数:11,代码来源:taskqueue.go

示例6: RetrieveAlbumInfo

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
}
开发者ID:pombredanne,项目名称:contacts.go,代码行数:10,代码来源:service.go

示例7: RetrieveContactSyncForUser

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
}
开发者ID:pombredanne,项目名称:contacts.go,代码行数:10,代码来源:service.go

示例8: VerifyValues

// 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
}
开发者ID:tobi,项目名称:go-openid,代码行数:61,代码来源:verify.go

示例9: RetrieveAlbums

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
}
开发者ID:pombredanne,项目名称:contacts.go,代码行数:11,代码来源:service.go

示例10: BuildQuery

// 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()
}
开发者ID:huwenshu,项目名称:chunkymonkey,代码行数:13,代码来源:server_auth.go

示例11: RetrieveProfileImage

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
}
开发者ID:pombredanne,项目名称:contacts.go,代码行数:13,代码来源:service.go

示例12: RetrieveContacts

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
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:49,代码来源:yahoo.go

示例13: SortedEscape

// (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
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:22,代码来源:escape.go

示例14: NewIssueComment

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
}
开发者ID:supr,项目名称:gohub,代码行数:17,代码来源:gohub.go

示例15: makeGetRequest

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
}
开发者ID:supr,项目名称:gohub,代码行数:17,代码来源:gohub.go


注:本文中的url.Values类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。