How to open a draft created with Gmail API in browser? - email

Im trying to create a gmail draft using gmail API and open it in a new tab.
When i try to open a draft using the following url : https://mail.google.com/mail/u/0/#drafts/ draft id , from a external web it does not open the draft. Instead it lists the drafts.
If i do the same in a Gmail tab it works as expected.
You can reproduce it following this steps
Chose any draft and copy its message id , you can use this
Create a url joining https://mail.google.com/mail/u/0/#drafts/ + the message id you got in the last step.
Open a new tab in Chrome and paste it, it will send you to your draft list.
If you paste the same url in the the same tab it will open the draft.
More information about the problem
It does not work with https://mail.google.com/mail/u/0/#drafts/?compose= neither
Chrome console throws this error when i try to open a draft from another tab
console error
I noticed if you open a draft the url is like this one https://mail.google.com/mail/u/0/#drafts?compose=JHrtffLJpZXxNwzKGMhcjvjBrqfPRwKWvkvJbtWpRffXldzxkNQhmkkBWJsHPbdSPdDgBVKpHKZMNtCVFgXrhwMCVjCdCRqTLJhGvqrXNKFZmJDGZ , this url works also to open the draft editor from other tabs, but where does the compose value come from?
I know it is not a API error or problem but if somebody had the same problem and know any way to solve it i will apreciate.
So the question is, how can i create a url to open a gmail draft using Gmail API ?

The way to make this url changed, now it works like this:
mail.google.com/mail/#inbox?compose=draft.message.id
If you list your drafts you get
{
"drafts": [
{
"id": "r5632827412362757569",
"message": {
"id": "174f4fa0dd96af123",
"threadId": "174f4f59344d6321"
}
}
],
...
}
So, to open this draft you need the following url :
mail.google.com/mail/#inbox?compose=174f4fa0dd96af123

Your goal:
To be able to open a browser tab directly focused on a specific draft of your choosing, from the drafts in your mailbox. (Correct me if I'm wrong).
Background:
You noticed that drafts have a "compose" parameter visible in the url when focused within the UI.
The drafts resource doesn't include the "compose" parameter, so we can't get it from the API, and it also isn't equal to the draft id.
Conclusion:
Since the parameter needed is not publicly available via API, you can't achieve your goal at the moment. You can request the feature to Google directly by creating a "Feature Request" for the Gmail API. Here's the link Issue Tracker.

Related

"Client Error" message when trying to implement an Rest API View

I'm creating an API with Drupal to serve a angular application. The problem is, when I create the view with Rest export and try to access it (via browser or postman), it gaves me an "Client error" message (and nothing more).
I'm using drupal-8.7.6, running with PHP7.3, mysql and apache 2. But I've tried at nginx also and the error appeared again.
To reproduce it, just add some contents, enable the Restful web services, jsonm hal and create a view that exports rest data.
I expect to access the information via GET request (using browser, postman or any other way)
Go to your View
Go to Format
Click on Settings beside Serializer
Finally check Json option and save.
You are done :)
find out what was happening
I was not specificating the format of output, so Drupal was searching for an html to serve. To workaround this, just add to url: ?_format=json, for example, if my view route is "/articles", it will be: http://drupal.dev/articles?_format=json
Go to the rest exports view, click on format setting and click accepted request format to json.

codename one sharebutton 400: Bad Request

I've been trying to use the native sharebutton integrated into the Codename one project, except that when I click "Post", a "400 : Bad Request" error appears. No exception is thrown, and I have no stacktrace in my console.
Code :
ShareButton sb = new ShareButton();
sb.addActionListener((evt) -> {
System.out.println("clicked");
});
hi.add(sb);
sb.setImageToShare("file://home/230r3EdWRk4kP6WDiMBM", "image/jpg");
sb.setTextToShare("Test facebook");
hi.show();
Another inssue is that the text to share is invisible.
Screenshot
400 just means bad request. This could be for many reasons. Make sure that the file path you provided exists etc..
AND
I seem to recall that Facebook no longer lets you share an Image and text at the same time. You can do one or the other. If you want to share something that has an image and text, you need to create a dynamic webpage that uses their Open Graph Markup, and share a link to that. Then it will be formatted nicely in the news feed.
It's been a while since I've had to do this, so I'm going by memory here... Things could have changed.
Thanks,
I fixed my problem by following the Facebook Demo at this link :https://github.com/codenameone/codenameone-demos/tree/master/FacebookDemo
Turns out that there are issues with the builtin share button, so you need to use multipart requests.

Facebook Ads API: How can I create ads preview without create campaign first?

I check a lot of documents, and flow like that:
Submit data to create Campaign, target, and AdCreative
Use ID of AdCreative to generate preview code
Display preview code to my site (to show to my user)
But I don't want to create Campaign, Targeting, and AdCreative before preview, just submit raw data of AdCreative to get preview code.
I found that doc https://developers.facebook.com/docs/graph-api/reference/generatepreviews/, and look like they can solve my problem... But it didn't work.
My test data is: https://graph.facebook.com/v2.6/generatepreviews?ad_format=RIGHT_COLUMN_STANDARD&creative={"object_story_spec":{"link_data":{"message":"msg","link":"http://kimkha.com?1","caption":"ccccc"}},"name":"NAME 1","body":"dddddd","title":"titititit","call_to_action_type":"OPEN_LINK","object_url":"http://kimkha.com"}&access_token=<token>
And the error:
{
"error": {
"message": "(#275) Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.",
"type": "OAuthException",
"code": 275,
"fbtrace_id": "GeckbxpU9gr"
}
}
I ran into the same problem and got past it, despite not being able to get a fully-functioning dynamic preview working. Here are some more pointers to help save others the pain.
The url needs to include an "ad account, business account or associated objects" like the error message states. For my case I used my ad account id (https://www.facebook.com/business/help/1492627900875762). The url changed to be the following base format: https://graph.facebook.com/v2.10/act_<your-app-id>/generatepreviews
When you get the response, you need to decode the body and you can use the url directly to test. I replaced \/ with /, & with & and removed the trailing slash. After this you get a url that should give you more specific error messages
I had to also specify a "page_id" parameter that the ad will be associated with. This is a sibling of "link_data" in the sample JSON listed above.
You may get error messages telling you to change the format of certain fields.
Eventually I got the error "Preview Not Available: Unable to display a preview of this ad. (fbtrace_id: Dsfql/z/qVI)" and finally lost the will to continue. The documentation is far from easy to follow and does not have clear examples.
I'm sorry I can't give a working solution, but for my case I was evaluating this API for a non-critical piece of work and timeboxing prevented me from proceeding. Hopefully I help save some time for someone else.
I ran into this problem. The solution for me was to use my app token instead of the Graph API Explorer's token. Hope this helps!
My two cents after struggling on this issue. My request had to be formatted as follows (this is using video data, but should extend to link data):
act_{ACT_ID}/generatepreviews
?ad_format=DESKTOP_FEED_STANDARD
&creative={object_story_spec:{
page_id:<PAGE_ID>,
video_data: {
image_url: <IMAGE_URL>,
call_to_action:{
type:"SHOP_NOW",
value:{
link: <URL>
}
}
}
}}
In this case, the call_to_action has to be placed inside the video_data (or link_data) parameter and has to be formatted as an object. I did also have to change & with &, as Matt mentions.

Is there an URL to open the Gmail compose window with a specific message ID in full-screen (pop-out)

I use the new Gmail API to create a draft for my user. The API response provides the newly created message ID.
I can then open the compose window with the URLhttps://mail.google.com/mail/#drafts?compose=[message-id]. However I would like to open a full-screen (popped-out) compose window. Is there an URL for that ? This URL must of course be parameterised with the message id.
To be more precise, this is what I get, and this is what I want.
Try this:
https://mail.google.com/mail?authuser=me#gmail.com#all/{message_id}
Just replace {message_id} with the actual ID string.

Expression Engine using the Champagne Extension troubleshooting

I have an issue in Expression Engine using the Champagne Extension where it won't allow me to send out campaigns. This extension utilizes https://www.campaignmonitor.com/ api to send out mass emails.
The Error I get is "HTML Content URL Required" when I try to send out campaigns form the back end of the Expression Engine Install.
What could be causing this issue that relates to the expression engine install?
This error is received anytime the URL to your html or text content is not visible. More often this is seen when someone forget to include the text version. A good way to test is to click the preview HTML/TEXT button and make sure both give you the correct results.
They cannot be blank.
For an alternative solution, be sure to checkout my add-on Postmaster. It allows clients to publish email campaigns just by creating a new entry. You can setup any number of configuration, so you can even send draft email to a test subscriber list. And since everything is within channel entries, you can use whatever fieldtypes you like, and it works with MailChimp as well as CampaignMonitor.
https://objectivehtml.com/articles/postmaster-the-definitive-email-solution-for-expressionengine