When ad type is set to "CPA", is it possible to use "offsite_conversion" with pixels, as we can do with "oCPM" ads?
For example, why can't I use the following:
$fbRequest['bid_info'] = array('ACTIONS' => $cData['creative_max_bid'] * 100);
$fbRequest['bid_type'] = 'CPA';
$fbRequest['conversion_specs'] = array('action.type' => array('offsite_conversion'), 'offsite_pixel' => $pixelRemoteId);
This kind of syntax works perfectly for oCPM ads but I wanted to try using CPA ads instead.
Instead, when I try to post the above to FB API, I get an exception with instructions to use "link_click" action instead.
Thank you,
Dan
According to the CPA documentation, no, CPA ads can't be used with offsite conversion pixels, only the actions listed in the documentation can be bid as CPA
Page Likes, Offer Claims, Offsite Link Clicks, Mobile App Installs
Related
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
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 am currently developing an app with which visitors of an event can take pictures using a webcam and upload them to Facebook using an AS3-application. I know I can connect to Facebook, because I can log the user out using the API and I can get all the information. The problem is that I can't post to their wall for some reason. I keep getting the following error:
error #2032: stream error. url: https://graph.facebook.com/********/feed
I use the following code to post to Facebook:
private function postFB(e:Event=null):void {
var _params:Object = new Object();
_params.uid = Facebook.getAuthResponse().uid;
_params.access_token = Facebook.getAuthResponse().accessToken;
_params.message = "I was at the Thanksgiving Day Event.";
//_params.picture = _bitmap;
Facebook.api("/me/feed", postComplete, _params, "POST");
}
As I've said before, I know I am connected to facebook because if I change "POST" to "GET" in my api-call, I get all the information of my account. I have the correct permissions as far as I know (read_stream, publish_stream, user_photos). I use GraphAPI_Web_1_8_1.swc as an api.
The documentation on the entire api is very poor, so I am trying to figure out the problem. It's been a few years since I've tried any of this, so my code has probably aged too far by now. So, any ideas what I'm doing wrong?
publish_stream is deprecated (since years?), you need to use publish_actions.
If that does not work, make sure the Access Token includes all the permissions, you can test this in the Debugger: https://developers.facebook.com/tools/debug/
Side note: AS3 is not getting used very often anymore, the last version of the the AS3 SDK is from 2011. It may be a good idea to switch to the JavaScript SDK.
I want to get all wall updates of user's google plus account like facebook.
I have seen official link for it which is
Google Plus Documentation for iOS
& I have downloaded sample from there which is here Google Plus SDK Sample
it works well for getting user's information like email id,profile name,user's friend list with images & for posting on google plus.
but I am not getting user's post & updates.
all I want is user's wall updates & user's friends updates from google plus like facebook does.
but from above link i have found nothing for getting wall updates.
I have searched google for this also & get nothing regarding above problem.
any help for above problem appreciated.
Thanks in advance
From a backend server you can easily perform this API call to read a user's public activities. You can see the REST API here:
https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.list
Combine this with a people.list and you can query for a user's friend activities on Google+.
On iOS, you probably don't want to make these API calls directly from a user's device. If you can, you should offload the work to a backend server to avoid overworking the mobile client. That said, you can perform an API query similar to listing people in circles:
GTLQueryPlus *query =
[GTLQueryPlus queryForActivitiesListWithUserId:#"me" collection:#"public"];
[[[GPPSignIn sharedInstance] plusService] executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusActivityFeed *actFeed,
NSError *error) {
}
If you put a breakpoint in the application on the function, the activities feed will be something like as follows:
(lldb) po actFeed
{
nextPageToken:"CAIQ44qZ58DgtwIgFCgB"
etag:""DOKFJGXi7L9ogpHc3dzouWOBEEg/UMVQXfw8ynZaTz31tpuZo473TsQ""
title:"Google+ List of Activities for Collection PUBLIC"
updated:"2013-07-16T04:04:34.697Z"
kind:"plus#activityFeed" items:[20]
}
The items array contains the actual activities that a user has publicly written on Google+.
I have some code like the following in my application:
message = "Hi, #John Doe!"
postID = fb.stream.publish(
message = loader.render_to_string('wall_post.phtml', {'message':message}),
action_links = simplejson.dumps([{'text': "Check out blah", 'href': "http://blah.dev"}]),
target_id = 'nf'
)
Is there any way to represent a facebook #mention in the message string so that facebook converts it to a profile link for the mentioned user?
I've also been looking for an answer to this. The facebook website uses the format:
#[139730900025:PhotoGrabber] is awesome
to represent the links but I haven't been able to make that work. I re-posted a thread on the facebook forum under the "Stream" category since your post wasn't getting any attention:
http://forum.developers.facebook.com/viewtopic.php?id=47885
Mention it's partially available by open graph now. You can use only when posting an open graph ACTION
Check:
https://developers.facebook.com/docs/opengraph/mention_tagging/
It seems still impossible to use #mention tagging in classic feed posting via API
I'm pretty sure this is impossible at the moment. If it were posible by using the format that tam7t suggested it should work... Your best bet is asking them to add that to their api stream parser.
This is not possible at the moment, sorry.
AFAIK facebook's API does not allow this. The only approach that I know of at the moment would be to write a screen scraper to do these posts using the format described by tam7t's answer. If you use the mobile version of facebook's site (m.facebook.com) it makes it much easier.
NOTE: This might be a violation of Facebook's Application TOS.
Edit:
Here is some ruby code that will do the trick, using the Mechanize Gem
require 'mechanize'
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
page = agent.get('http://m.facebook.com')
form = page.forms.first
# enter credentials
form.pass = 'user password'
form.email = 'user#example.com'
page = agent.submit form
# go straight to page to post on
page = agent.get("http://m.facebook.com/wall.php?id=PAGE_ID_NUM")
form = page.forms.first
form.message = "#[139730900025:PhotoGrabber] is awesome"
page = agent.submit form
NOTE: Obviously (as tiagoboldt kindly pointed out) it would be wrong to store / utilise the credentials of other people in your application. This approach would only be appropriate for making posts from a facebook account that you controlled.
That said, back to the original question of putting an #mention in a wall post, I have noticed that whilst the post and #mention go up on the wall fine, this method does not propagate the post to the mentioned user/page's wall. Not sure if that is important to you.