Ejemplo n.º 1
0
// Returns the credentials attached to an OAuth authentication token.
// This method does not require user authentication, but the request must be api-signed.
func CheckToken(client *flickr.FlickrClient, oauthToken string) (*CheckTokenResponse, error) {
	client.EndpointUrl = flickr.API_ENDPOINT
	client.ClearArgs()
	client.Args.Set("method", "flickr.auth.oauth.checkToken")
	client.Args.Set("oauth_token", oauthToken)
	client.ApiSign()

	response := &CheckTokenResponse{}
	err := flickr.DoGet(client, response)
	return response, err
}
Ejemplo n.º 2
0
// Delete a photoset
// This method requires authentication with 'write' permission.
func Delete(client *flickr.FlickrClient, photosetId string) (*flickr.BasicResponse, error) {
	client.Init()
	client.HTTPVerb = "POST"
	client.Args.Set("method", "flickr.photosets.delete")
	client.Args.Set("photoset_id", photosetId)

	client.OAuthSign()

	response := &flickr.BasicResponse{}
	err := flickr.DoPost(client, response)
	return response, err
}
Ejemplo n.º 3
0
// Set the order of photosets for the calling user.
// Any set IDs not given in the list will be set to appear at the end of the list, ordered by their IDs.
// This method requires authentication with 'write' permission.
func OrderSets(client *flickr.FlickrClient, photosetIds []string) (*flickr.BasicResponse, error) {
	client.Init()
	client.HTTPVerb = "POST"
	client.Args.Set("method", "flickr.photosets.orderSets")
	sets := strings.Join(photosetIds, ",")
	client.Args.Set("photoset_ids", sets)

	client.OAuthSign()

	response := &flickr.BasicResponse{}
	err := flickr.DoPost(client, response)
	return response, err
}
Ejemplo n.º 4
0
// Create a photoset specifying its primary photo
// This method requires authentication with 'write' permission.
func Create(client *flickr.FlickrClient, title, description, primaryPhotoId string) (*PhotosetResponse, error) {
	client.Init()
	client.HTTPVerb = "POST"
	client.Args.Set("method", "flickr.photosets.create")
	client.Args.Set("title", title)
	client.Args.Set("description", description)
	client.Args.Set("primary_photo_id", primaryPhotoId)

	client.OAuthSign()

	response := &PhotosetResponse{}
	err := flickr.DoPost(client, response)
	return response, err
}
Ejemplo n.º 5
0
// Modify the photos in a photoset. Use this method to add, remove and re-order photos.
// This method requires authentication with 'write' permission.
func EditPhotos(client *flickr.FlickrClient, photosetId, primaryId string, photoIds []string) (*flickr.BasicResponse, error) {
	client.Init()
	client.HTTPVerb = "POST"
	client.Args.Set("method", "flickr.photosets.editPhotos")
	client.Args.Set("photoset_id", photosetId)
	client.Args.Set("primary_photo_id", primaryId)
	photos := strings.Join(photoIds, ",")
	client.Args.Set("photo_ids", photos)

	client.OAuthSign()

	response := &flickr.BasicResponse{}
	err := flickr.DoPost(client, response)
	return response, err
}
Ejemplo n.º 6
0
// Edit set name and description
// This method requires authentication with 'write' permission.
func EditMeta(client *flickr.FlickrClient, photosetId, title, description string) (*flickr.BasicResponse, error) {
	client.Init()
	client.HTTPVerb = "POST"
	client.Args.Set("method", "flickr.photosets.editMeta")
	client.Args.Set("photoset_id", photosetId)
	client.Args.Set("title", title)
	if description != "" {
		client.Args.Set("description", description)
	}

	client.OAuthSign()

	response := &flickr.BasicResponse{}
	err := flickr.DoPost(client, response)
	return response, err
}
Ejemplo n.º 7
0
Archivo: test.go Proyecto: gloob/gfxBot
// A testing method which echo's all parameters back in the response.
// This method does not require authentication.
func Echo(client *flickr.FlickrClient) (*EchoResponse, error) {
	client.EndpointUrl = flickr.API_ENDPOINT
	client.Args.Set("method", "flickr.test.echo")
	client.Args.Set("oauth_consumer_key", client.ApiKey)

	response := &EchoResponse{}
	err := flickr.DoGet(client, response)
	return response, err
}
Ejemplo n.º 8
0
Archivo: test.go Proyecto: gloob/gfxBot
// Noop method
// This method requires authentication with 'read' permission.
func Null(client *flickr.FlickrClient) (*flickr.BasicResponse, error) {
	client.Init()
	client.SetOAuthDefaults()
	client.Args.Set("method", "flickr.test.null")
	client.OAuthSign()

	response := &flickr.BasicResponse{}
	err := flickr.DoGet(client, response)
	return response, err
}
Ejemplo n.º 9
0
Archivo: test.go Proyecto: gloob/gfxBot
// A testing method which checks if the caller is logged in then returns their username.
// This method requires authentication with 'read' permission.
func Login(client *flickr.FlickrClient) (*LoginResponse, error) {
	client.Init()
	client.SetOAuthDefaults()
	client.Args.Set("method", "flickr.test.login")
	client.OAuthSign()

	loginResponse := &LoginResponse{}
	err := flickr.DoGet(client, loginResponse)
	return loginResponse, err
}
Ejemplo n.º 10
0
// Delete a photo from Flickr
// This method requires authentication with 'delete' permission.
func Delete(client *flickr.FlickrClient, id string) (*flickr.BasicResponse, error) {
	client.Init()
	client.EndpointUrl = flickr.API_ENDPOINT
	client.HTTPVerb = "POST"
	client.Args.Set("method", "flickr.photos.delete")
	client.Args.Set("photo_id", id)
	client.OAuthSign()

	response := &flickr.BasicResponse{}
	err := flickr.DoPost(client, response)
	return response, err
}
Ejemplo n.º 11
0
// Gets information about a photoset.
// This method does not require authentication unless you want to access a private set
func GetInfo(client *flickr.FlickrClient, authenticate bool, photosetId, ownerID string) (*PhotosetResponse, error) {
	client.Init()
	client.Args.Set("method", "flickr.photosets.getInfo")
	client.Args.Set("photoset_id", photosetId)
	// this argument is optional but increases query performances
	if ownerID != "" {
		client.Args.Set("user_id", ownerID)
	}

	// sign the client for authentication and authorization
	if authenticate {
		client.OAuthSign()
	} else {
		client.ApiSign()
	}

	response := &PhotosetResponse{}
	err := flickr.DoGet(client, response)
	return response, err
}
Ejemplo n.º 12
0
// Return the public sets belonging to the user with userId.
// If userId is not provided it defaults to the caller user but call needs to be authenticated.
// This method requires authentication to retrieve private sets.
func GetList(client *flickr.FlickrClient, authenticate bool, userId string, page int) (*PhotosetsListResponse, error) {
	client.Init()
	client.Args.Set("method", "flickr.photosets.getList")
	if userId != "" {
		client.Args.Set("user_id", userId)
	}
	// if not provided, flickr defaults this argument to 1
	if page > 1 {
		client.Args.Set("page", strconv.Itoa(page))
	}
	// perform authentication if requested
	if authenticate {
		client.OAuthSign()
	} else {
		client.ApiSign()
	}

	response := &PhotosetsListResponse{}
	err := flickr.DoGet(client, response)
	return response, err
}
Ejemplo n.º 13
0
// Get the photos in a set
// This method requires authentication to retrieve photos from private sets
func GetPhotos(client *flickr.FlickrClient, authenticate bool, photosetId, ownerID string, page int) (*PhotosListResponse, error) {
	client.Init()
	client.Args.Set("method", "flickr.photosets.getPhotos")
	client.Args.Set("photoset_id", photosetId)
	// this argument is optional but increases query performances
	if ownerID != "" {
		client.Args.Set("user_id", ownerID)
	}
	// if not provided, flickr defaults this argument to 1
	if page > 1 {
		client.Args.Set("page", strconv.Itoa(page))
	}
	// sign the client for authentication and authorization
	if authenticate {
		client.OAuthSign()
	} else {
		client.ApiSign()
	}

	response := &PhotosListResponse{}
	err := flickr.DoGet(client, response)
	return response, err
}