Impossible to delete Facebook Objects - javascript

I'm trying to delete an object created by a story, but I'm getting the following error :
(#100) Cannot delete object not created via the API
I used the FB.api in javascript to create a story with news.reads (works), I can delete the story with the ID too. But the object created for the story still exists, I can see it in the Graph API, but cannot delete it.
I want to fix this issue because if I try to create a story with the same article link, if I change the content (the same link refers to a new article), facebook will keep the old settings (title, image and description don't change).

You can force facebook to re-scrape your site when you use scrape=true in your next call:
FB.api(
'/',
'post',
{id: <your article url>, scrape: 'true'},
<your callback function>
);

Related

Facebook Graph API Share method break the href link

I'm using Facebook Graph API with Javascript to allow the user to share a link. Simple enough.
Javascript code:
var _link = 'http://example.com/ca.a/4102/540/en/1/31';
function share() {
FB.ui({ method: 'share',
href: _link,
redirect_uri: _link,
quote: 'simple name'
},
function (response) { }
);
}
This operation results it a link generated by Facebook API:
https://www.facebook.com/v2.8/dialog/share?app_id=596131650587698&channel_url=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter%2Fr%2F0sTQzbapM8j.js%3Fversion%3D42%23cb%3Df2c247478a4c94c%26domain%3Dwebcand.com%26origin%3Dhttp%253A%252F%252Fwebcand.com%252Ff2f0001bcf7065%26relation%3Dopener&display=popup&e2e=%7B%7D&href=http%3A%2F%2Fwebcand.com%2Fca.a%2F4102%2F540%2Fen%2F1%2F31&locale=en_US&name=simple%20name&next=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter%2Fr%2F0sTQzbapM8j.js%3Fversion%3D42%23cb%3Df572851e5571f8%26domain%3Dwebcand.com%26origin%3Dhttp%253A%252F%252Fexample.com%252Ff2f0001bcf7065%26relation%3Dopener%26frame%3Df1d6415a361a248%26result%3D%2522xxRESULTTOKENxx%2522&quote=Click%20here%20to%20take%20the%20interview&sdk=joey&version=v2.8
Note the &next= parameter. Facebook has wrapped the link I provided with additional data, redirecting it to Fstaticxx.facebook.com.
So now, the share feed looks like this:
The "Object reference not set to an instance of an object" error message is happening because the link I provided expects the format http://example.com/ca.a/A/B/C/D/E and if one of these / params is missing, the exception occurs. So obviously the link alteration causes this.
Passing the URL as A-B-C-D-E works fine, so my conclusion is that the / signs are being removed.
Any suggestion how to fix this?

Filter Active Users based on page title- Google Analytics

I need to show active visitors on my website based on Page title.
Example : If the user is Contact Us page, then onlycount of active visitors on 'Contact us' page is to be shown instead of entire site.
I am following Embed API Third Party Visualizations
I tried the following code but it is not working
var activeUsers = new gapi.analytics.ext.ActiveUsers({
container: 'active-users-container',
pollingInterval: 5,
query: {
filters:'ga:pageTitle==Contact'
}
});
Please help me to resolve this issue.
As I mentioned in the Github issue opened about this same question, what you're asking to do is not possible with the current ActiveUsers Embed API component (it's just for demo purposes, it's not intended to be a full-featured Real Time query component).
However, this component could easily be modified to support your use case. You'd just have to update the lines that make the API request to add your query parameters.
Here is the relevant line of code that makes the request:
gapi.client.analytics.data.realtime
.get({ids: options.ids, metrics: 'rt:activeUsers'})
.then(function(response) {
// ... do something with the response
});
To add your filter, you'd just have to change that line to something like this:
gapi.client.analytics.data.realtime
.get({
ids: options.ids,
metrics: 'rt:activeUsers',
filters: 'ga:pageTitle==Contact'
})
.then(function(response) {
// ... do something with the response
});
Of course, you'd probably rather refactor the component to accept an options object (as you show in your question), so you don't have to hard code your query, but I'll leave it up to you to make that code change.
To point you in the right direction, you should read the Embed API guide: Creating Custom Components. You'll probably also need to reference the Shared Component Reference to see the methods all components can call.
I tried this Show active visitors after filtering
it worked.

How to create and edit unpublished facebook post with image?

I want to create unpublished image post on facebook and then edit the message attached to it.
I can create an image by doing:
/me/photos
url: somewhere
published: false
caption: 'abc'
This, due to documentation should return
Struct {
id: numeric string,
post_id: string,
}
But it doesn't return post_id. If published is set to false the post_id is omitted. When I visit created photo on facebook I can edit attached caption and other parameters of the photo. But when I try to do it trough API I can only edit very limited amount of parameters, described here:
https://developers.facebook.com/docs/graph-api/reference/photo/#Updating
I also tried different approaches, of which most promising was to post unpublished photo, then create unpublished post with image attached. Since I'm trying to post to a page I'm using this endpoint:
https://developers.facebook.com/docs/graph-api/reference/v2.5/page/feed
/me/feed
caption: 'abc'
published: false
object_attachment: (id-from-previous-request)
If I could do it like this I could later edit the message, and the post would look the same as when using /me/photos normally.
I cannot do
/me/feed
caption: 'abc'
published: false
url: somewhere
Because this results with link post(and requires link parameter as well), which is different in look from image post.
I cannot figure what I am doing wrong - I just want to create unpublished post with attached image and then edit it. It's possible trough webpage, but all my attempts trough API have failed.
The related post_id for photo_id is always generated like this(for page):
page_id + '_' + photo_id
In case the photo was posted into different edge then instead of page_id corresponding id is used, for example it would be user id, if it was posted onto edge user/photos.
This behavior isn't documented anywhere where I could find it, nor it is guaranteed to work in the future. I contacted facebook support yet they didn't clarify if it's intended. They only said that it's by design that post_id is not returned.

How to build custom URL by adding ?&params in Angular?

I'm trying to build a custom URL and update the URL as the user selects items in my dashboard.
For example, after clicking a few items the URL could/should look like:
#/dashboard?&portfolio=GOOG&ticker1=GOOG
Currently the URL only ends in /dashboard (console.log($location.path());)
How would I update the $location.path() to add params like so? There's plenty of questions/answers and guides on getting params from the URL, but how would you update the URL in the first place?
Say if you want to add the following:
?&portfolio=GOOG&ticker1=GOOG
just organize your params in an object, like
var params = {
portfolio: GOOG,
ticker1:GOOG
}
and use,
$location.url('/dashboard ').search(params);
Hope it helps !!!
I think I'm understanding what you're saying. I believe you could use a PHP GET function to do that. A GET function in PHP will add the information you're trying to communicate to the backend to the URL, while the POST function does not.

post an image on my profile tagging a friend facebook

I've a facebook application and I'm using a Feed and Share Dialog popup to post an image on my personal profile. My goal is to tag a friend of mine (instead of posting it on his timeline, I can not change this behaviour for a customer request - considered less spammy).
So, the question is, is there a way to tag a friend in the post? According the API of Feed and Share Dialogs it's not possible, but how can I do that?
Here's the code.
var sIdPersonalProfile = [my personal id profile];
var sIdFriendProfile = [my friend id profile];
var hFacebookData = {
method: 'feed',
display : 'popup',
name: 'NAME_APP',
caption: 'CAPTION_APP',
description: 'DESCRIPTION_APP',
picture: 'URL_APP',
to: sIdPersonalProfile
};
FB.ui(hFacebookData, callback);
thanks in advance.
Assuming you have already figured out how to POST the image to your personal profile. Then, to tag yourself or someone else is quite easy. You need to issue POST request to one of the following urls:
https://graph.facebook.com/PHOTO_ID/tags/USER_ID
https://graph.facebook.com/PHOTO_ID/tags?to=USER_ID
or, if you need to tag more than one user you need to pass an array of user ids...
'https://graph.facebook.com/PHOTO_ID/tags?tags=[{"tag_uid":"1234"}, {"tag_uid":"12345"}]`
This operations will require the following permissions are passed in the scope parameter...
user_photos
publish_stream
You can also specify some extra parameters such as the coordinates of the location of the tag in the image and a tag caption. For more info, check out the Facebook Developer Photo API to publish tags

Categories

Resources