micnews / apple-news Goto Github PK
View Code? Open in Web Editor NEWA Node.js client for interacting with the Apple News API :newspaper:
A Node.js client for interacting with the Apple News API :newspaper:
please write some demo code for how I can use create an article, not getting the input fields
Hi so basically I am using apple new API for analytics, so I need to send a post request to the api to create a report, the closest thing I found on the internet to my task is the create article function you have. but I am failing miserably to create the right signature.
I have succeeded in making it work with python but it didn't work in Javascript. I think I am failing at creating the right canonical_request.
here is the python line for creating the canonical_request:
canonical_request = method + url + date + content_type + json.dumps(payload)
whereas;
content_type = "application/json"
payload = {"data":{"reportType":"ARTICLE_DETAIL", "startDate":"2022-11-07", "timezone":"-0000"}}
I tried copying your method by doing this:
let canonicalRequest = Buffer(method + host + endpoint + date + content_type + JSON.stringify(payload) , 'ascii')
but unfortunately didn’t work.
Would love to know if you have any input on this or if you can help me solve this problem.
Thanks,
Theres logic in there that overrides the default Apple News API behaviour with no documentation that this happens. As outlined in the Apple docs on isPreview
:
Default value: True if your channel has not yet been approved to publish articles in Apple News Format; False if your channel has been approved.
But this module explicitly sets it to true
if not defined.
i couldn't find any definitive info on timeout settings - it seems like it just uses the default OS socket timeout?
Here is the structure of how I'm using this
appleNewsObject = {"title":"dd","version":"1.5","language":"en","identifier":"dd","metadata":{"thumbnailURL":"ddd"},"layout":{"columns":"10","width":"1024","margin":"85","gutter":"20"},"components":[{"role":"heading1","text":"HEADING"},{"role":"title","text":"dd"},{"role":"intro"},{"role":"byline","text":"dddd"},{"role":"body","format":"html","text":"
Add some text here
"},{"role":"body","format":"html","text":"Add some text here
"}]}https://www.mydomain.com/test/article.json
My Json file has same data as "appleNewsObject"
var metadata = {}
client.createArticle({
channelId: accounts[index].channelId,
article: appleNewsObject,
bundleFiles: [
'https://www.mydomain.com/test/article.json',
metadata
],
}, (err, response) => {
if (err) {
console.log(err);
} else {
console.log(response);
}
});
This is giving me file type error for file "https://www.mydomain.com/test/article.json"
Please reply asap. I need the solution really urgent
const { createClient } = require('apple-news');
ReferenceError: apple_news is not defined
at Object. (C:\Users\Debasish.Bose\Projects\AppleNews\backend\functions\index.js:6:23)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.