Creative and Objective Mismatch while creating Carousal Ad by using Marketing API - ruby-on-rails

I'm creating Carousel Ad via marketing API. During the Ad creation Facebook through "Creative and Objective Mis-match" error. However, Campaign and Adset are successfully creating.
I have changed the objective as per Facebook documentation. I tried multiple combinations but got errors. e.g: "Billing event invalid for optimisation goal, Creative and Objective Mismatch, Invalid Creative for Objective"
Doc_link
res = ad_account.ads.create({
status: 'ACTIVE',
name: ' SDK',
adset_id: adset.id,
creative: {
object_story_spec: {
page_id: fb_page_id,
link_data: {
child_attachments: [
{
description: "$8.99",
image_hash: "1ea34798e1ba00ffaab318dc",
link: "www.facebook.com",
name: "Product 1",
video_id: "42920500794",
call_to_action: {
type: "LEARN_MORE",
value: {
link: "www.facebook.com"
}
}
},
{
description: "$9.99",
image_hash: "8299deb1e053f7601c4f99f44",
link: "www.facebook.com",
name: "Product 2",
video_id: "378442876",
call_to_action: {
type: "LEARN_MORE",
value: {
link: "www.facebook.com"
}
}
},
],
:link => "www.facebook.com",
},
}
}
})
I need to create a complete carousel ad by using marketing API.

Related

Auto-generated Mutation Does Not Create Relationship

I want to test auto-generated CRUD mutations created by calling makeAugmentedSchema from 'neo4j-graphql-js'. There is no problem with creating nodes but creating relationship does not work for me. Please advise on what I am doing wrong here.
Schema:
type Bio{
id: ID!
description: String
}
type Person{
id: ID!
name: String
dob: Date
gender: String
bioRelation: [Bio] #relation(name: "HAS_BIO", direction: "OUT")
}
Mutation:
I am following the Interface Mutations guidance https://grandstack.io/docs/graphql-interface-union-types to create mutation.
mutation {
p: CreatePerson(
name: "Anton",
gender: "Male") {
name
gender
id
}
b: CreateBio(
description: "I am a developer") {
description
id
}
r: AddPersonBioRelation(
from: {id: "p"},
to:{id: "b"}
){
from{
name
}
to{
description
}
}
}
It create Person and Bio nodes but no any relationship gets created between the two:
{
"data": {
"p": {
"name": "Anton",
"gender": "Male",
"id": "586b63fd-f9a5-4274-890f-26ba567c065c"
},
"b": {
"description": "I am a developer",
"id": "a46b4c22-d23b-4630-ac84-9d6248bdda89"
},
"r": null
}
}
This is how AddPersonBioRelation looks like:
Thank you.
I am new to GRANDstack, and I have also been struggling with these types of issues myself. I have typically broken this out separate mutations (in javascript) and used the return value for each as values for the next mutation. for example:
await createIncident({
variables: {
brief: values.brief,
date,
description: values.description,
recordable: values.recordable,
title: values.title
}
}).then((res) => {
addIncidentUser({
variables: {
from: user.id,
to: res.data.CreateIncident.id
}
});
});
the problem that i see in the example you've provided is that you are specifying a string value for from and to as "p" and "b" respectively and NOT the p.id and b.id return values from the parent mutations.
it's fine of me to point that out but what i can't for the LIFE of me figure out is how to properly reference p.id and b.id in the mutation itself. in other words you are trying to send
from: { id: "586b63fd-f9a5-4274-890f-26ba567c065c"}
to: { id: "a46b4c22-d23b-4630-ac84-9d6248bdda89" }
but in reality you are sending
from: { id: "p"}
to: { id: "b" }
which aren't actually references in neo4j so it fails.
if we can figure out how to properly reference p.id and b.id we should get this working.
Thank you, #dryhurst. It appears that there is no way to reference id of newly created nodes, but I found a solution by introducing temp id property. Please see the discussion of this matter and final solution on:
https://community.neo4j.com/t/auto-generated-mutation-does-not-create-relationship/21412/16.

iOS facebook login response does not contain profile data

I implemented Facebook login for both Android and iOS using react-native-facebook-login. I followed all of the instructions and it is working perfectly on Android. It works on iOS, but the response does not contain profile data.
Android Response:
declinedPermissions: [],
provider: 'facebook',
profile:{
id: '121212121212121212',
name: 'XYZ',
email: 'xyz#gmail.com',
first_name: 'XYZ',
last_name: 'XYZ',
age_range: { min: 21 },
link: 'https://www.facebook.com/app_scoped_user_id/121212121212121212/',
picture: { data: { is_silhouette: false,url: 'https://scontent.xx.fbcdn.net/v/t1.0-1/12/12.jpg?oh=12&oe=12' } },
gender: 'male',
locale: 'en_US',
timezone: 5.5,
updated_time: '2017-02-01T08:16:35+0000',verified: true },
type: 'success',
credentials: {
permissions: [ 'public_profile', 'contact_email', 'user_friends', 'email' ],
tokenExpirationDate: '2017-05-13T14:56:36.690+0530',
userId: '1212121212121212121',
token:'ababababababababbababababa' }
But on iOS, the response is incomplete and there is no profile data:
declinedPermissions: [],
credentials: { tokenExpirationDate: '2017-05-14T14:58:09+05:30',
permissions: [ 'email', 'contact_email', 'user_friends', 'public_profile' ],
userId:'12121212121212121',
token:'abababababababababababababa' },
missingPermissions: []
The code is same for both Android and iOS. And I did all of the configuration changes in Xcode. Is there something else that needs to be done to get the profile data on iOS?
We need to do another API call where we send the token which was generated into this API call.
fetch('https://graph.facebook.com/v2.5/me?fields=email,name,first_name,last_name,friends&access_token=' + YOUR_GENERATED_TOKEN)
.then((response) => response.json())
.then((json) => {
})
.catch(() => {
reject('ERROR')
})
This call will give you the profile details.

Migrating from Mandrill to SparkPost -- Rails API

I am migrating from Mandrill to SparkPost and have a Rails back-end.
The data structure I currently have is the following --
message = {
subject: "Welcome",
merge_vars: [{
rcpt: user.email,
vars: email_vars(user)
}],
to:[{
email: user.email,
name: user.name
}],
track_clicks: true,
track_opens: true,
inline_css: true,
}
This sends the response --
m = Mandrill::API.new
template_content = []
result = m.messages.send_template 'email-confirmation', template_content, message
Would I need to update the JSON data structure at all?
Once JSON is good, how do I pass values to specific template with SparkPost?
I attempted the following --
m = SparkPost::Client.new()
template_content = []
result = m.messages.send_template 'email-confirmation', template_content, message
But I have also seen this --
host = 'https://api.sparkpost.com'
SparkPost::Request.request("#{host}/api/v1/transmissions", API_KEY, {
recipients: [
{
address: { email: user.email },
substitution_data: {
first_name: user.name,
email: user.email
}
}
],
content: {
template_id: 'email-confirmation'
},
substitution_data: {
name: user.name,
email: user.email
}
})
Appreciate the help!
If you're using the official gem, it has a convenient method called send_payload which you can use to send a prepared payload.
The substitution_data inside recipients collection is a per recipient substitution.
For example, I've following templates.
To send using this template, this is my complete code
sp = SparkPost::Client.new() # pass api key or get api key from ENV
payload = {
recipients: [
{
address: { email: 'RECIPIENT1' },
substitution_data: {
name: 'User one',
username: 'userone'
}
}, {
address: { email: 'RECIPIENT2' },
substitution_data: {
name: 'User two',
username: 'user2'
}
}
],
content: {
template_id: 'test-template'
},
substitution_data: {
company: 'Awesome company'
}
}
response = sp.transmission.send_payload(payload)
p response
The email will look like
Hello User one, Your username, userone, is created. Thanks Awesome company

active model serializer flat structure

I'm bulding my api server for my React/Redux app, where i need some flat response from server to manage and reduce my state.
For example, when i have this response:
[{
id: 1,
title: 'Some Article',
author: {
id: 1,
name: 'Dan'
}
}, {
id: 2,
title: 'Other Article',
author: {
id: 1,
name: 'Dan'
}
}]
How can i make it looks like:
{
result: [1, 2],
entities: {
articles: {
1: {
id: 1,
title: 'Some Article',
author: 1
},
2: {
id: 2,
title: 'Other Article',
author: 1
}
},
users: {
1: {
id: 1,
name: 'Dan'
}
}
}
}
Best feature is what each key is articles/users id, so i can easily get it from the response and merge it in my front-end app.
You can achieve this with AMS, but you will have to write a custom adapter, as none of the stock ones provide this exact format.
JSON API (and the corresponding AMS JsonApi adapter) solve this issue, but the format is slightly different from the one you want.

OAuth 2.0 Scope for Google Apps users' names with google-api-nodejs-client

I'm trying to use Google's 'google-api-nodejs-client' package (https://github.com/google/google-api-nodejs-client) to handle OAuth 2.0 authentication.
I've modified the example in examples/oauth2.js to console.log the entire profile object.
What scope can I use to correctly extract users' 'givenName' and 'familyName' if they're authenticating using a Google Apps account? Using the following scope:
scope: [
'https://www.googleapis.com/auth/plus.login',
'https://www.googleapis.com/auth/plus.profile.emails.read'
]
returns the following response once authenticated:
{ kind: 'plus#person',
etag: '"LONG STRING"',
emails: [ { value: 'example#example.example', type: 'account' } ],
objectType: 'person',
id: '123456',
displayName: '',
name: { familyName: '', givenName: '' },
image:
{ url: 'https://lh3.googleusercontent.com/ etc etc',
isDefault: false },
isPlusUser: false,
language: 'en_GB',
circledByCount: 0,
verified: false,
domain: 'example.example' }
I tried fooling around with the API on the API Explorer (https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=me) and only needed the 'https://www.googleapis.com/auth/plus.login' scope to get my familyName and givenName.
Perhaps the user that you are requesting the data from does not have a given and family name set?

Resources