I've hit a blocker with POST'ing of HTML content to the https://graph.facebook.com api. I'm able to successfully POST to the endpoint and I receive a status ID as a response. When I then use a GET on the endpoint to check the status, the error messages tell me my content is malformed. I'm able to manually publish the exact same HTML content on my channel in Instant Articles and I get no warnings about the formatting of the HTML. I've also tried using the sample article HTML provided by Facebook and that returns error messages as well. Any advice is appreciated. Here are samples of my requests:
POST /{my_page_id}/instant_articles?access_token={my_access_token}& html_source=<!DOCTYPE html><html lang="en" prefix="op: http://media.facebook.com/op HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}
<!---Facebook Sample Article Content--->
<!doctype html>
<html lang="en" prefix="op: http://media.facebook.com/op#">
<head>
<meta charset="utf-8">
<!--Canonical URL of the article from site -->
<link rel="canonical" href="{my_Facebook_approved_domain/canonical_url}">
<link rel="stylesheet" title="{my_stylesheet}" href="#">
<!--Article Title-->
<title>{my_article_title}</title>
<meta property="fb:article_style" content="{my_stylesheet}">
</head>
<body>
<article>
<header>
<!-- The header image shown inside your article -->
<figure>
<!-- First Figure from the article -->
<img src="{my_image_url}">
</figure>
<!-- Article Title -->
<h1>{my_article_title}</h1>
<!--Article Teaser-->
<h2>{my_article_subtitle}</h2>
<!-- The authors of the article -->
<address>{list_of_authors}</address>
<!--The published and last modified time stamps-->
<time class="op-published" dateTime="2019-01-10T16:00">January 10 2019, 04:00 PM</time>
</header>
<p>{my_content}</p>
<p> Read the Full Story at {my_site}</p><br>
<footer>
<!-- Copyright details for your article -->
<small>© 2019 {my_site}. All Rights Reserved.</small>
</footer>
</article>
</body>
</html>
After submitting the POST request, I get a response that looks like this:
{
"id": "2005563182874064"
}
I then GET the article status endpoint by calling:
GET /{page_id}?access_token={my_access_token}& fields=errors,html_source,instant_article,status HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}
...and the response I get from that endpoint is as follows:
{
"errors": [
{
"level": "ERROR",
"message": "AttValue: \" expected"
},
{
"level": "ERROR",
"message": "Couldn't find end of Start Tag html"
},
{
"level": "ERROR",
"message": "Missing Article's Canonical URL: There is no URL specified for this article. A canonical URL needs to be claimed and placed within the HTML to generate an Instant Article. Refer to URLs under Publishing Articles in the Instant Articles documentation for more information on claiming and inserting a canonical URL."
}
],
"html_source": "<!DOCTYPE html><html lang=\"en\" prefix=\"op: http://media.facebook.com/op",
"status": "FAILED",
"id": "2005563182874064"
}
The canonical URL is certainly present in my HTML and I've tripled checked that it's listed in the Configuration/Tools/Connect your site area of my Facebook page. Again, I'm able to manually upload the same HTML and preview it using the Pages App on a mobile device. It's only failing when I try to push the content via the API.
I'm testing all of my calls with POSTMAN and will then convert this code to Python3. Again, thanks for your help.
You always want to place payload data in the body of the request for POSTs and as a query string for GET. Anytime an API calls for data that looks extreme for a URL (can't be longer than 2083 characters), that's a key indicator that this is probably not a GET.
Related
I'm trying to send a POST request on http://xyz:8002/LATEST/rest-apis using Firefox's rest client. I have added two headers Content-Type: application/xml and Authorization:Basic which I selected using the dropdown UI. The body of the request is -
<rest-api xmlns="http://marklogic.com/rest-api">
<name>Status Dashboard</name>
<database>r75-xyz-v11</database>
<port>8020</port>
</rest-api>
In response I'm getting a 401 Unauthoried.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>401 Unauthorized</title>
<meta name="robots" content="noindex,nofollow"/>
</head>
<body>
<h1>401 Unauthorized</h1>
</body>
</html>
I have Admin rights and I gave the same credential in the UI box that came after selecting authentication basic.
Is port 8002 configured for BASIC or DIGEST (the default) authentication?
By the way, I don't think the name of the appserver can contain a space.
OneNote tags on page elements (e.g. <p>) show up in the HTML content returned via the REST API prefixed with a data-tag=attribute. But if the complete note is tagged, that tag doesn't seem to show up in the returned content.
Or am I missing something?
[EDIT]
Here's a screenshot showing the complete note tagged as 'Important' (star symbol) :
I can't see anything in the returned content that relates to that tag:
<html lang="en-US">
<head>
<title>Didi Chuxing = Jean Liu</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div style="position:absolute;left:48px;top:67px;width:576px">
<img width="480" height="270" src="https://www.onenote.com/api/v1.0/me/notes/[...]
<br />
<p lang="en-NZ" style="font-size:14pt;margin-top:0pt;margin-bottom:0pt">credit : Fast Company</p>
</div>
</body>
</html>
[EDIT]
This question has led to a UserVoice request for this feature to be added in to the API. Only one vote so far - maybe this mention will get it more ;)
The note-tag you are showing is in the title of the page.
Currently, the OneNote API does not support returning note tags in the title. This is different to note-tags in the body, because the title tag is returned in our API as part of the HTML->head->title - other note-tags are returned within the HTML->body. I believe the right way of representing this information is to add the data-tag attribute to the HTML->head->title element.
I suggest creating a UserVoice item for this feature.
https://onenote.uservoice.com/forums/245490-onenote-developer-apis
I'm having some issues when I try to create a note using OneNote REST API.
This happens in my application and also when I try to use for testing purpose the apigee tool: https://apigee.com/onenote/embed/console/onenote
After some tests, i've tested the example available on OneNote documentation:
http://msdn.microsoft.com/en-us/library/office/dn575438(v=office.15).aspx#sectionSection3
On apigee, I have the following parameters:
Method: POST
Header: Content-Type: text/html and the corresponding authorization token.
Request Body:
<!DOCTYPE html>
<html>
<head>
<title>One Simple Note</title>
<meta name="created" content="2013-06-11T12:45:00.000-8:00"/>
</head>
<body>
<p>This is a simple non-multi-part HTML page.</p>
</body>
</html>
The note is sent successfully and I receive 201.
When I check my OneNote page, the note is created, but the body of the note is empty.
What am I doing wrong?
Turns out we had a bug in our system that caused messages under 16kb to be ignored. We just fixed it, so you shouldn't have any problems now!
I am working on an integration with OneNote using the REST API.
I'm trying to create a note but I'm always receiving 400 response code, with the following message: "The multi-part payload was malformed."
URL:
https://www.onenote.com/api/v1.0/pages
Headers:
Content-Type: multipart/form-data; boundary=NewPart
Authorization: Bearer myToken
--NewPart
Content-Type: text/html
Content-Disposition: form-data; name="Presentation"
<!DOCTYPE html>
<html>
<head>
<title>One Note test</title>
<meta name="created" content="2014-04-13T10:36:28+01:00"/>
</head>
<body>
<p>Hello OneNote World</p>
</body>
</html>
--NewPart--
If I try the same request in the apigee tool (https://apigee.com/onenote/embed/console/onenote), it's working perfectly.
I have initially tried to not use multi-part, but all the notes sent without multi-part were missing the note body on the OneNote site. Here is my post on this other issue:
OneNote body is not sent when using non-multipart REST
Make sure the presentation part lines end in CRLF. We've noticed that when using some tools like Fiddler, when you try to reissue and edit a previous request, it removes the CRLF endings from the lines.
Here's what I tried for Facebook Debugger tool:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fdevstmaws.linesofphp.com%2Fvideo%2Findex%2F52f0fd544eab99ae28000106
Scrape Information:
Response Code 401
Fetched URL http://devstmaws.linesofphp.com/video/index/52f0fd544eab99ae28000106
Canonical URL http://devstmaws.linesofphp.com/video/index/52f0fd544eab99ae28000106
Warning
Critical Errors That Must Be Fixed
Bad Response Code URL returned a bad HTTP response code.
Warning
Errors That Must Be Fixed
Missing Required Property The 'og:type' property is required, but not present.
Notice
Open Graph Warnings That Should Be Fixed
Inferred Property The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.
URLs
Graph API https://graph.facebook.com/1419346681640654
Scraped URL See exactly what our scraper sees for your URL
The URL that I would like to share is: http://devstmaws.linesofphp.com/video/index/52f0fd544eab99ae28000106
What could be the reason? It's not scraping my site anymore.
Scraper response: Document returned no data
Meta tags:
<meta property="og:image" content="http://devstmaws.linesofphp.com/static/img/logo_facebook.jpg" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<meta property="og:title" content="Check out my awesome video!" />
<meta property="og:site_name" content="Check out my awesome video!" />
<meta property="og:description" content="SearchTheMusic gives you the ability to legally add music to your videos and share them with the world!" />
<meta property="og:url" content="http://devstmaws.linesofphp.com/video/index/52f0fd544eab99ae28000106" />
Facebook has to be able to access the URL for the Open Graph tags to work, and your URL is protected by a password. Only public URLs are possible. You get the same error as if you cancel the authorization popup.
I give you other way also. Here I remove javascript SDK.Other are all same
Taken intermediate step.
So I take this steps:
I have created folder , outside of project folder(password protected).i.e. outerface.And create a file,say projectfront.php
First:
defined a outside url
Here, I have used aforesaid file path. So now Facebook can't abuse me.
<?php
$faceproject_url='[your servar path]/outerface/projectfront.php';
?>
<div class="fb-share-button" data-href="<?php echo $faceproject_url; ?>" data-type="button_count"></div>
Second:
In outerface/projectfront.php-
I have written(with proper doctype) as:
......
........
<script>
function xyz()
{
url=[Give your target link];// it will your project page, which you want to share.
window.location=url;
}
</script>
</head>
<body onload="xyz()">
<?php
ob_start();
?>
Please wait....
</body>
</html>
[please do proper html]
So now if any user click on your share button, share'll be successfully done and Facebook will not obstacle us. Also If you click on link on Facebook(in wall) after share, you will redirect successfully to your link defined in projectfront.php.
Thanks
Atanu Mitra
You usually receive this error when the fetched URL to the page and the OG:URL do not match.
Using javascript SDK for Facebook
I have overcome with intermediate step.
My project url is also password protected.
So I take this steps:
I have created folder , outside of project folder(password protected).i.e. outerface.And create a file,say projectfront.php
Call a function using Facebook sdk and use FB.ui({ with method:feed. And I have taken a tricks. In link, I have used aforesaid file path. So now Facebook can't abuse me.
<div>share</div>
<script>
function sharesend()
{
FB.ui({
method: 'feed',
link: '[your servar path]/outerface/projectfront.php',
picture: [give picture, if you can],
caption: [give any caption],
description: [give any description],
.....................,
..............
},
function(response){}
);
}
</script>
In outerface/projectfront.php- I have written(with proper doctype) as:
......
........
<script>
function xyz()
{
url=[Give your target link];// it will your project page, which you want to share.
window.location=url;
}
</script>
</head>
<body onload="xyz()">
<?php
ob_start();
?>
Please wait....
</body>
</html>
[please do proper html]
So now if any user click on your share button, share'll be successfully done and Facebook will not obstacle us. Also If you click on link on Facebook(in wall) after share, you will redirect successfully to your link defined in projectfront.php.
Thanks
Atanu Mitra