I am trying to use Explicit Sharing with built in watch action. Here is my code
$post_action = $facebook->api(
'me/video.watches',
'POST',
array(
'video' => "$post-link",
'fb:explicitly_shared'=>true
)
);
When I set fb:explicitly_shared to false the activity is shown on both recent activity and activity log. But when i set it to true the activity is only shown on activity log, not to the recent activity, not to the users timeline.
I have read all the documentation on Facebook about Explicit Sharing but i cant find out why is this happening.
All the results I mentioned are made with Test Users of this app.
Maybe I have first to submit it on Facebook for approval before I will be able to test it?
After some days of work i found out that Application testers have a bug with explicit share. I tried to post with my developers account and works good!
Related
I've created a Facebook app, linked it with a business, submitted and passed review, the business is verified, contracts signed, the app has leads_retrieval permission, the app status is now live.
I can test it under the webhooks link in the side menu, my end point receives the test data from Facebook. The data shown below is received by my server.
When I test using the lead ads testing tool I instantly get a 102, server error, and nothing is received by my server. See below for the message.
I've spent so long getting to this stage and every step has been painful!
Can anyone suggest why using the lead ads testing tool results in an error and what I can do to resolve the issue.
Cheers
I've been struggling with this too.. Apparently you can't use it on development apps anymore. Found the answer here: https://stackoverflow.com/a/57397525/8439792
I think I found your problem! It is when you subscribe to your apps. Here is the link that shows the subscribed_fields and scope should be:
https://stackoverflow.com/a/54713182/7313872
I was going straight from the demo and the subscribed_fields is set to 'feeds' and the scope was only manage_pages. You need to change it like in the example in the above link. I will also provide the snippets I changed below:
subscribed_fields - in subscribe apps function
FB.api(
'/' + page_id + '/subscribed_apps',
'post',
{access_token: page_access_token, subscribed_fields: 'leadgen'},
function(response) {
console.log('Successfully subscribed page', response);
}
);
scope - end of facebook login function
{scope: ['manage_pages', 'leads_retrieval']});
Hope this helps!
Facebook had the problem in their startup documentation for the webhooks. I have notified them in a bug, and does look like they have fixed the documentation to now subscribe to "leadgen" and not "feeds".
https://developers.facebook.com/support/bugs/681262475926363/
https://developers.facebook.com/docs/marketing-api/guides/lead-ads/quickstart/webhooks-integration/
I am trying to create Ad using facebook-java-sdk
val adCreative = new AdAccount(ACCOUNT_ID, context).createAdCreative()
.setName(s"Test Creative +$TEST")
.setObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldLinkData(
new AdCreativeLinkData()
.setFieldCaption("http://www.field-caption.com")
.setFieldImageHash(attachment1.getFieldImageHash)
.setFieldLink("http://www.google.co.in")
.setFieldMessage("try it out")
)
.setFieldPageId(FACEBOOK_PAGE)
)
.execute()
val ad = new AdAccount(ACCOUNT_ID, context).createAd()
.setName(s"Test Ad +$TEST")
.setAdsetId(adSet.getId)
.setCreative(adCreative.getId)
.setCreative(new AdCreative().setFieldId(adCreative.getId()))
.setStatus(Ad.EnumStatus.VALUE_PAUSED)
.execute()
However the createAd calls fails and results into exception with
com.facebook.ads.sdk.APIException$FailedRequestException: {"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1772103,"is_transient":false,"error_user_title":"Instagram Account Is Missing","error_user_msg":"You're using Instagram as a placement. Please select an Instagram account to represent your business in your Instagram ads, or select a Facebook Page to use instead.","fbtrace_id":"FtpWRXVY1tH"}}
This was working fine couple of days back, but all of sudden has started throwing an exception. Any help would be appreciated.
I'd like to add to this answer since i just fought with this issue.
Our long running app that managed boosting just stopped working this month and was throwing the error the OP mentioned.
It appears that the default settings on Facebook's side changed. The docs state that the defaults are facebook, audience_network, messenger
Looking in the Ads Manager, it shows that the placement for the failed boost attempt now includes instagram as a placement. There doesn't seem to be any mention of this change anywhere that I could find.
So I did have to change the call to explicitly define facebook, audience_network, messenger as my publisher_platform setting and not rely on the defaults.
You can explicitly specify publisher platform to publish only on facebook
val adSet = new AdAccount(ACCOUNT_ID, context).createAdSet()
.setName(s"Test AdSet +$TEST")
.setLifetimeBudget(20000L)
.setStartTime(currentDateTime.toString())
.setEndTime(currentDateTime.plusDays(1).toString())
.setCampaignId(campaign.getId())
.setIsAutobid(true)
.setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
.setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_POST_ENGAGEMENT)
.setTargeting(
new Targeting()
.setFieldCustomAudiences(List(idNameCusAudience).asJava)
.setFieldPublisherPlatforms(List("facebook").asJava)
)
.setStatus(AdSet.EnumStatus.VALUE_PAUSED)
.execute()
None of these answers really answer what you need to do if you want to include Instagram.
In order to post to instagram you need an instagram account ID.
Every single page on Facebook has (or can have) an instagram 'account' without the user creating one.
What you need to do is (in this order):
Check if they have an instagram linked (if they do you use this ID)
Check for page_backed_instagram_accounts to see if their page has an instagram account that Facebook made for them to be able to advertise (this account is hidden and cannot be found on instagram) if they have this, use the ID from this account.
If for some reason their page has no instagram nor does it have page_backed_instagram_accounts then you will need to create a page_backed_instagram_account
The endpoints you are looking for are:
https://graph.facebook.com/v3.1/[pageId]?fields=instagram_accounts
https://graph.facebook.com/v3.1/[pageId]?fields=page_backed_instagram_accounts
I am using this plugin:
https://www.npmjs.com/package/cordova-plugin-facebook-push-campaign
Also followed the instructions in this link. I have added this line:
cordova.plugins.FacebookPushCampaign.register(pushToken);
But it seems that this is not reflecting in my FB analytics. When I tried creating push campaign, and sent a push notification it results to 0 notifications delivered.I manually send a notif on my phone and it works. So maybe the plugin is not registering the token toFB correctly?
Have anyone tried this plugin before?
Okay, after a day of debugging. I followed again what is stated in the plugin's documentation and it seems working fine now. What happened is that I was confused about the comment in the documentation.
// grab the token and pass it to Facebook
cordova.plugins.FacebookPushCampaign.register(pushToken);
So what I did was (which is INCORRECT):
cordova.plugins.FacebookPushCampaign.register(pushToken.registrationId); //I passed the device token itself
But I realized that the FB analytics accepts the whole response of the registration event (CORRECT):
pushPlugin
.init({
ios: {
badge: 'true',
sound: 'true',
alert: 'true',
clearBadge: 'true',
}
})
// wait for the plugin to register the Push Token
.on('registration', function(pushToken) {
// grab the token and pass it to Facebook
//pushToken looks like {'registrationId':xxxxx}
cordova.plugins.FacebookPushCampaign.register(pushToken); //Yes, pass the response of the registration event
});
LESSON: Read the documentation. If the documentation is confusing, test it and see if you misunderstood something (like what happened to me).
So I am building a restaurant app and one of the features I want is to allow a user of the app to see photos from a particular restaurant's Instagram account.
And I want a user to be able to see this without having to login to their Instagram account, so they shouldn't even need an Instagram account for this to work.
So I have read this answer How can I get a user's media from Instagram without authenticating as a user?
And I tried what it said and used the client_id(which I recieved when I registered my app using my personal Instagram account), but I still get an error back saying :
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
The endpoint I am trying to hit is :
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
So do I absolutely need an access token for this to work(and thus have to enforce a user to log in) ?
If I do, then is there way to generate an access token somehow without forcing the user log in?
I believe there is a way around this, as the popular dating app Tinder has this desired functionality I am looking for, as it allows you to see photos from people's Instagram account without having to log in! (I have just verified this 5 minutes ago!)
Any help on this would be much appreciated.
Thanks.
Edit April 2018: After facebook privacy case this endpoint is immediately put out of service. It seems we need to parse the JSON embedded in <script> tag directly within the profile page:
<script type="text/javascript">window._sharedData = {"activity_counts":...
Any better ideas are welcome.
You can use the most recent link
GET https://www.instagram.com/{username}/?__a=1
to get latest 20 posts in JSON format. Hope you put this to good use.
edit: other ways aren't valid anymore:
https://www.instagram.com/{username}/media/
Instagram used to allow most API requests with just client_id and without access_token, the apps registered back in the day still work with way, thats how some apps are able to show instagram photos without user login.
Instagram has changes the API specification, so new apps will have to get access_token, older apps will have to change before June 2016.
One way you can work around this is by using access_token generated by your account to access photos. Login locally and get access_token, use this for all API calls, it should not change, unless u change password,if it expires, regenerate and update in your server.
Since the endpoints don't exist anymore I switched to a PHP library -
https://github.com/pgrimaud/instagram-user-feed
Installed this lib with composer:
composer require pgrimaud/instagram-user-feed "^4.0"
To get a feed object -
$cache = new Instagram\Storage\CacheManager();
$api = new Instagram\Api($cache);
$api->setUserName('myvetbox');
$feed = $api->getFeed();
Example of how to use that object -
foreach ($feed->medias as $key => $value) {
echo '<li><img src="'.$value->thumbnailSrc.'"></li>';
}
I'm using PHP and FacebookAPI, all is almost ok except for a strange error.
I tried to find solution on facebook developers site and google but with no luck.
This is the scenario:
Event 368441533230244 is created
User 100004484143351 is invited to the event 368441533230244
Now I want to remove the user from the event.
According to Facebook API docs, my APP own the permissions
rsvp_event
user_event
friend_event
And many others :)
Now calling the api:
$FB->api("368441533230244/invited/100004484143351", 'DELETE');
I obtain an Exception with the following details:
["result":protected] => array(1) {
["error"] => array(3) {
["message"] => string(8) "(#1002) "
["type"] => string(14) "OAuthException"
["code"] => int(1002)
}
I was unable to find something about Error Code 1002, and as you can see there is no error description.
Any idea? :)
Thanks in advance
Ok, this seems to be a side effect of the Events Timezone migration.
Events created using a web browser at facebook.com will behave like the migration is enabled. But your app probably has the Events Timezone migration disabled. This is causing a mismatch and the issue.
So do this: Keep the Events Timezone migration disabled in your app and create events using the Graph API instead of the web-ui/browser. This will ensure events are created and modified with the same migration setting.
You can check your app's migrations settings in the App Dashboard > Advanced > Migrations.
If you are using the Graph API Explorer to create events, make sure you select your App from the dropdown list "Application", at the top.