Error in creating videos with CTA button using Ads API - php

I'm using Facebook Ads API to create unpublished page posts. I have a problem when I try to publish those page posts which are videos with call-to-action button. I create unpublished page posts successfully and then I publish the unpublished posts from power editor, but it shows this message when I try to publish unpublished page posts I created:
Sorry, something went wrong. Please try again.
I tried to remove call_to_action from the code, posts get published without any problem. I'm using Marketing API integrated with my app and use user access token with those permissions:
manage_pages, publish_pages, ads_management, business_management, public_profile.
I need help to be able to publish unpublished posts (videos) with CTA button.
Here's the code I use:
$video_data = new AdCreativeVideoData();
$video_data->setData(array(
AdCreativeVideoDataFields::DESCRIPTION => '<DESCRIPTION>',
AdCreativeVideoDataFields::IMAGE_URL => '<IMAGE_URL>',
AdCreativeVideoDataFields::VIDEO_ID => '<VIDEO_ID>',
AdCreativeVideoDataFields::CALL_TO_ACTION => array(
'type' => AdCreativeCallToActionTypeValues::LEARN_MORE,
'value' => array(
'link' => '<URL>',
'link_title' => '<LINK TITLE>',
'link_caption' => '<LINK CAPTION>',
'link_format' => 'VIDEO_LPP',
),
),
));
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID => '<PAGE_ID>',
AdCreativeObjectStorySpecFields::VIDEO_DATA => $video_data,
));
$creative = new AdCreative(null, 'act_<Ad_ACCOUNT_ID>');
$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));
$creative->create();
Hope to get help, Thanks!

To publish unpublished post through API, you can make a POST call like /?is_published=true.
For the error from PowerEditor, it is lack of information for me to share any insights. It would be preferable to file a bug to Facebook for this type of issues. You are safe to share more details in the bug tool and Facebook can also pull information from their logs for troubleshooting.
In case you do not know the link to Facebook Bug Tool. https://developers.facebook.com/bugs/

Related

Videos uploaded with facebook api are visible to me but not to others

Today i've uploaded some clips using Facebook video api and there is a problem.
The problem is that videos uploaded on my page are visible to me but not to other people. Not even the other admins can't see them. Now the obvious answer would be "the privacy".
But that's the thing, it's public. I don't know what i'm doing wrong
$attachment = array(
'access_token' => $this->token,
'name' => isset($story->name) ? $story->name : $story->title,
'description' => $story->description,
'source' => '#' . realpath($story->resource)
);
$result = $this->facebook->api($this->getUploadUrl($story->page, $story->type), 'post', $attachment);
It's all working fine. I'm not getting any errors. The result from this request would be somthing like
{"id":"693098840722877"}
Thank you!
I think maybe you for got Privacy.
attachment = array(
'access_token' => $this->token,
'name' => isset($story->name) ? $story->name : $story->title,
'description' => $story->description,
'source' => '#' . realpath($story->resource),
'privacy' => json_encode(array( 'value' => 'EVERYONE' ))
);
Oh dear God. The application was in "sandbox" mode. So that's why other people could not see the posts
For anyone else having the same problem, As Samuel Todosiciuc mentioned, check your App live status. I was going insane trying to figure out why public posts of programmatically uploaded videos were not showing for others.
I didn't find any sandbox setting per se, it was putting it live.
Go to your App page > App review > "Make (your app) public?" > put it to live.

bigger images in facebook posts when posting via facebook php sdk

I have the following code to generate a facebook post for a page using graph api.
$page_info = $facebook->api("/$pageId?fields=access_token");
if (!empty($page_info['access_token'])) {
$attachment = array(
'access_token' => $page_info['access_token'],
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$status = $facebook->api("/$pageId/feed", "post", $attachment);
Posts from one of my facebook pages look like below image.
link to image - How my posts look
Then i came across some other pages, whose posts look like below image. As you can see, these preview images are large and appear above the post. When we click them, we are redirected to another website's page. So i had to assume, we are not posting this as image. Please note that i need to post my link, big thumbnail and my custom description as shown in this image.
How to achieve this?
link to image - How my posts should look like
bigger images in facebook posts when posting
Use the Open Graph to create the custom stories.

Facebook 'caption' option not showing up for non-timeline Facebook

So I'm creating posts to the facebook user's wall using Graph API
I'm referring to the 'caption' as stated here:
http://nocturnsoft.com/devblog/?p=906
when I specified the 'caption' option, the text in the caption would appear properly for profiles that uses the timeline, but for profile that use the old style, the caption would not appear...
Am I doing something wrong here or is this how it's supposed to be....If it is how it's supposed to be, how would I display text beneath the link for the Facebook post for non timeline profiles
btw: I'm using Facebook PHP SDK
In my apps the post data array looks like this and the caption (message) is present on both new and old profiles.
/* post to fb */
$post = array(
'access_token' => $fb_access_token,
'message' => 'THIS IS YOUR CAPTION HERE',
'link' => 'LINK TO YOUR SITE OR APP HERE',
'picture' => 'URL TO IMAGE HERE',
'name' => 'APP NAME HERE',
'description' => 'AWESOME DESCRIPTION ABOUT YOUR APP GOES RIGHT HERE!'
);
$res = $facebook->api('/me/feed', 'POST', $post);
Hope this helps. If so don't forget to say so! :)

why facebook api post to users and not on the page itself?

i'm using this code to post to my application page as the page and not the admin:
$page_info = $facebook->api("/344722062246773?fields=access_token");
$attachment2 = array('message' => $row["nwmsg"],
'access_token' => $page_info['access_token'],
'name' => $row["nwnm"],
'caption' => $row["nwsubject"],
'picture' => 'http://itradegame.com/itrade/' . $row["nwposter"],
'description' => $row["nwtext"],
'actions' => array(array ('name'=> 'Play!','link'=> 'https://apps.facebook.com/itradee/')));
$result = $facebook->api('/344722062246773/feed/','post',$attachment2);
but the wierd thing is the users who likes the page can see the post on thier news feed but can't see it on the page itself.
why?
Because of the new timeline feature, posts by users (all except the page itself) will be listed under 'Recent Posts by Others on { PAGE_NAME}' section.
Please check the section.

How can I post to the wall of a Facebook Fan Page using PHP and Open Graph API

Sample code is appreciated, I can't seem to find any simple examples of this online.
Using the new Facebook PHP-SDK, it's very easy to accomplish this.
Requirements:
Extended Permissions, depending on your needs
Page ID
Now as I said, depending on your requirements you may need offline_access, manage_pages, but for now this is the simplest straight forward way of doing this:
After downloading the PHP SDK, and in the example.php file:
Acquire the publish_stream permission:
<fb:login-button perms="publish_stream"></fb:login-button>
After successful authentication, you post to the page wall the same way you do it for normal user profile (and with the same options too, message, picture, link, name, caption, description, source):
$page_id = '123456789';
$feed_array = array(
'message' => "Hello world!"
);
$page_post = $facebook->api("/$page_id/feed","post",$feed_array);
Result:
Please note that this approach requires you being an administrator of the page.
in this change the /me/feed/ to your page id, I did't try....Just check
$attachment = array('message' => 'some meesgae',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'mylink.com',
'description' => 'this is a description',
'actions' => array(array('name' => 'Get Search', 'link' => 'google.com')) );
$result = $facebook->api('/me/feed?access_token='.$access_token, 'post', $attachment);

Categories