How does one get a better quality picture from passport-facebook, the picture that I recieve in photos[0].value is 50x50 which is pretty poor, I wish to get atleast 150x150.I was trying to mess with link - no luck. Is it possible to retrieve better quality profile picture?
Edit: My current fb strategy setup:
passport.use(new FacebookStrategy({
clientID: 'xxxxxx',
clientSecret: 'xxxxx',
callbackURL: 'http://localhost:4242/facebook/cb',
profileFields: ['id', 'name', 'displayName', 'photos', 'hometown', 'profileUrl'],
passReqToCallback: true
}, ...
You should be able to specify the profileFields property as described in
https://github.com/jaredhanson/passport-facebook#profile-fields
like the following to retrieve a larger picture:
passport.use(new FacebookStrategy({
// clientID, clientSecret and callbackURL
profileFields: ['id', 'displayName', 'picture.type(large)', ...]
},
// verify callback
...
));
or you could change the strategy.js file of the passport-facebook module at line 221 to
'photos': 'picture.type(large)'
See
https://github.com/jaredhanson/passport-facebook/blob/master/lib/strategy.js#L221
Related
I'm trying to generate the documentation for an function based view in DRF using the drf-spectacular library.
The response that I'm trying to generate should look like this:
As you can see "data" is a list.
I tried to do the following:
class DocumentSerializer(serializers.Serializer):
date = serializers.IntegerField(default=123)
total_documents = serializers.IntegerField(default=1890)
#extend_schema(
parameters=[
OpenApiParameter(name='authorization', description='Authorization token', required=True, type=str, location=OpenApiParameter.HEADER),
],
description='Info about the endpoint',
responses={
200: inline_serializer(
name='Successfull response',
fields={
"result_code": serializers.IntegerField(default=200),
"result_description": serializers.CharField(default="Transaccion Exitosa"),
"data": DocumentSerializer(),
}
),
},
)
#api_view(["GET"])
def my_endpoint_function(request):
pass
As you can see "data" should be a list of DocumentSerializer, but I don't know how to achieve that. The result I'm obtaining with the code above is the following:
Because I don't know how to make that data has a list of DocumentSerializer.
It will be great if you can help me, I've searching in the documentation but at this point I'm stuck.
I'm not 100% sure, but adding many=True should definitely generate a list.
"data": DocumentSerializer(many=True)
Is it possible to generate a swagger UI page (and redoc for that matter) that has examples for both application/json and x-www-form-urlencoded request bodies? I can get examples for application/json, but not when selecting x-www-form-urlencoded as the request type fro the swagger/redoc UIs.
I'm using the following decorator for the "create" method (in a ModelViewSet)
#extend_schema(request=MySerializer)
where MySerializer looks like the following...
#extend_schema_serializer(
examples=[
OpenApiExample(
'Example input',
description='Creation of an alias',
value={
'user_id': 1234567890,
'obj_id': 288,
'alias': 'my alias'
},
request_only=True,
response_only=False,
),
],
)
class MySerializer(serializers.Serializer):
user_id = serializers.IntegerField()
obj_id = serializers.IntegerField()
alias = serializers.CharField(max_length=50)
The swagger/redocs UIs will happily provide an example dropbox with "Example Input" for an application/json request body (whereby selecting the example will populate the json), but for x-www-form-urlencoded will just show a form to fill in, with no example dropbox in order to populate the fields.
I can get examples (and their selection drop boxes) for query strings, i.e. when making GET endpoints that use OpenApiParameter e.g.
#extend_schema(
parameters=[
OpenApiParameter(name='q', description='Query string to search for', required=True, type=str,
examples=[
OpenApiExample(
'Search query',
value='foobar'
),
]
),
...
]
)
where selecting a drop box entry will populate the text field.
However, for x-www-form-urlencoded, this doesn't seem to get generated?
Is this possible? Am I doing something wrong?
When it comes to example data, Redoc is very manual in that there is very little automatic generation of examples based on the schema.
AFAIK SwaggerUI does generate a basic example from the schema, however also only for JSON.
If you want to have application/x-www-form-urlencoded examples, you likely need to specify each one manually. Not sure if the juice is worth the squeeze there.
Now to drf-spectacular: OpenApiExample are by default JSON, so if you want a different encoding you need to explicitly set it and also provide a properly encoded value string:
OpenApiExample(
'Form-encoded example 1',
value='YOUR HANDMADE FROM ENCODED DATA STRING',
media_type='application/x-www-form-urlencoded'
)
I'm using the campaign manager API to upload a local file into an advertiser; the script works all the way through without any errors. However, when checking the advertiser directly, there isn't a new creative asset. The changelogs also don't show any new changes. The script run (without the google authentication - OAuth 2.0, which is working to expectation on other calls):
def upload_creative_asset(
service, profile_id, advertiser_id, asset_name,path_to_asset_file,
asset_type):
"""Uploads a creative asset and returns an assetIdentifier."""
# Construct the creative asset metadata
creative_asset = {
'assetIdentifier': {
'name': asset_name,
'type': asset_type
}
}
media = MediaFileUpload(path_to_asset_file, mimetype='image/gif')
if not media.mimetype():
media = MediaFileUpload(path_to_asset_file, 'application/octet-stream')
response = service.creativeAssets().insert(
advertiserId=advertiser_id,
profileId=profile_id,
media_body=media,
body=creative_asset)
return response
path_to_creative = "automated_dcm_loading/test.gif"
upload_creative_request = upload_creative_asset(service,advertiser_id='10229XXX',profile_id='6414XXX',asset_name='test.gif',path_to_asset_file=path_to_creative,asset_type='image')
upload_creative_request.execute()
The response is:
{'kind': 'dfareporting#creativeAssetMetadata',
'assetIdentifier': {'type': 'IMAGE', 'name': 'test.gif'},
'id': '475828XXX',
'richMedia': False}
This tells me it's worked but doesn't appear in campaign manager anywhere.
UPDATE: This is only half the process to get an asset to appear in campaign manager. The next step for those who need this is to use this exact output in a creatives().insert() function to wrap the asset with a creative. Without this creative step your asset/image/video will sit on a server somewhere with nowhere for it be shown.
My app is being set up to use HelloSign through it's API. I'm trying to create a Template using a PDF I have. My goal is to have fields in the PDF that I can pre-fill in before sending it to the customer to their signature. I'm going to pre-fill things in like their full name, their account #, etc.
I've uploaded the PDF into the Template tool and added the custom fields using the GUI tool. However, as I've found on the documentation and other StackOverflow questions, I need to set these custom fields to "Me (when sending)" in the Assigned to setting. However, for me, this option doesn't appear at all (See image).
As a result, when my API calls the sendWithTemplate function with this as one of the parameters, I'm getting an error of "Invalid custom field parameters".
I'm on the Pro plan currently. Also, if HelloSign is reading this, you should let people on a free account use a template in test mode or something, no reason to make me sign up with CC to test using templates.
const opts = {
test_mode: 1,
template_id: templateId,
clientId: '<my client id>',
subject: 'Test Document',
message: 'Sign this test document',
signers: [
{
email_address: 'email#email.com',
name: 'Klay'
}
],
custom_fields: [
{ personName: "Klay Curry" }
]
};
HelloSign.signatureRequest.sendWithTemplate(opts).then((res) => {
console.log("RES", res);
}).catch((err) => {
console.log("ERR", err);
});
I'm a HelloSign API support engineer and happy to help.
Apologies, we are updating our documentation, but the custom field should be set to "Sender" which is the same as "Me (when sending)".
Also, the custom_fields object should be set like so with NodeJs:
custom_fields = [ { "name" : "personName", "value" : "Klay Curry" } ]
As for your piece about letting folks on a free account use a template in test mode, I believe if you just create a template past your template limit, it will automatically say that the template is locked and can be used in test_mode.
I will also reply to you on the ticket you opened for this.
Hey all,
I've made a facebook application for a contest, which allows users to upload their photo. Once uploaded, the photo gets posted to a dedicated album on their profile. Once the photo is there, the users should collect as many likes as possible.
Currently i have tried both the Facebook Graph API and Facebook FQL to retrieve the amount of likes, but the retrieved likes don't always match the likes on a users profile.
Some users claim to have more then 200 likes, yet the API only returned a maximum of 101 likes so far.
All users are requested to grant the application the following permissions:
user_hometown, publish_stream, read_stream, user_photos and offline_access
Using Facebook PHP SDK 3.0.1 I tried this FQL query to collect the amount of likes of a photo:
# fql query
$fql = "SELECT object_id FROM like WHERE object_id=" . $photo_id;
# api request
$request = array(
'method' => 'fql.query', 'query' => $fql
);
# run batch request
$likes = $this->facebook->api($request);
# return like count
return count($likes);
I also tried the following Graph API request (Also with Facebook PHP SDK 3.0.1) to collect the amount of likes of a photo:
$likes = $this->facebook->api($photo_id.'/likes');
return count($likes['data']);
Strangely, neither seem to return correct results. I can understand if the API is slightly inaccurate, but according to the API some pictures recieved 100 likes this morning and then 0 likes a few hours later.
Does anyone have any ideas what i might be doing wrong? Do the photo's and their albums need to be public? Do the people who liked the photo need to have a public profile in order to show up in the API? Do i need to request additional permissions?
Any help or suggestions will be greatly appreciated!
Just had the same problem here. The likes seems to be paginated by hundreds by default. Override this setting by using the "LIMIT" query option.
Does anyone have any ideas what i might be doing wrong?
yes, I believe that it is against Facebook policy to use their likes plugin for a contest. See: https://www.facebook.com/promotions_guidelines.php
# fql query
$fql = "SELECT like_info FROM photo WHERE object_id=" . $photo_id;
# api request
$request = array(
'method' => 'fql.query', 'query' => $fql
);
# run batch request
$likeInfo = $facebook->api(array(
'method' => 'fql.query', 'query' => $fql
));
var_dump($likeInfo);die;
=> get like info of photo