Code Monkey home page Code Monkey logo

apple-news's Introduction

Apple News API client

API wrapper module for Apple News API https://developer.apple.com/library/ios/documentation/General/Conceptual/News_API_Ref/index.html

Supports creating, reading, updating, deleting, and searching articles. Also supports reading and listing sections, as well as reading channels!

For Node versions < 4, use apple-news@^1. For Node versions >= 4 use apple-news@^2

Install

npm install apple-news --save

Usage

var client = createClient({
  apiId: '<API-ID>',
  apiSecret: '<API-SECRET>'
});

Methods

client.readChannel ({ channelId }, cb)
client.listSections ({ channelId }, cb)
client.readSection ({ sectionId }, cb)
client.createArticle ({ channelId, article, bundleFiles, isPreview = true }, cb)
client.readArticle ({ articleId }, cb)
client.updateArticle ({ articleId, revision, article, isPreview = true }, cb)
client.deleteArticle ({ articleId }, cb)

License

MIT

apple-news's People

Contributors

chris-olszewski avatar danmakenoise avatar greenkeeperio-bot avatar iefserge avatar kesla avatar ryanscottaudio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apple-news's Issues

How to create the signature if I am sending a normal post request?

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,

What is the bundle files in create article.

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

isPreview defaults to true

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.

apple_news is not defined

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.