I'm new to FB marketing API.
I'm using php to create a function which handles the creation of the adVideo:
public function getUploadVideo() {
Api::init($this->appId, $this->appSecret,$this->token);
$video = new Advideo(null, 'act_' . $this->adAccountId);
$video->{AdVideoFields::SOURCE} = 'https://s3-us-west 2 .amazonaws.com /unittest-tvpage-com/testsuite/videos/big_buck_bunny.mp4';
$video->{AdVideoFields::NAME} = 'test_video';
$x = $video->create();
The video I'm using does not need any permissions and it can be directly downloaded.
When I run the function I get the following error message:
Type: FacebookAds\Exception\Exception
Code: 26
Message: couldn't open file "https://s3-us-west-2.amazonaws.com/unittest-tvpage-com/testsuite/videos/big_buck_bunny.mp4"
Any ideas why the file could not be opened?
Thanks
As per documentation:
https://developers.facebook.com/docs/marketing-api/reference/ad-account/advideos
To add the video using the url is file_url not source. The source parameter is used for uploading a file.
Related
i have problem when i upload video from (form HTML)
i use Laravel FFMpeg package
this code from my controller
$file = $request->file('video'); // take video request
FFMpeg::fromDisk('public')
->open(['vid\vid_one.mp4' , $file]) // concat video here and i think there is a problem
->export()
->concatWithoutTranscoding()
->save('contacct.mp4');
You have to store that video on that point where you are using ffmpeg open function with this function:
$request->file('video')->storeAs('folderName', $request->video->getClientOriginalName(), 'diskName');
I am trying to develop a login to my website functionality with Facebook account using Facebook Graph API.
I am in trouble to retrieve profile image of logged in user because Facebook returns URL but when I try it on the navigator it says that it needs permission to download it.
For example the URL:
https://platform-lookaside.fbsbx.com/platform/profilepic/?asid......
PS : I make the 3 points
I want to know if there is any method to get a correct URL to save it in the database or if there is any method to download the image with PHP, I tried this on my end, but no success.
$img = file_get_contents($dataata['picture']['url']);
$file = '/img/test.jpg';
file_put_contents($file, $img);
Message returned is :
file_put_contents(/img/test.jpg): failed to open stream: No such file
or directory
Any solution?
Trying to upload videos using V3 API from a form. When specifying the path to the video I'm using $videoPath = file_get_contents($_FILES["file"]["name"]); I've also tried it with out the get_file_contents and it tells me it can't find the file. I must be missing something, is there a way to upload directly from a form post without having to upload it to my server, than upload it to YouTube?
You dont allow to download video files from youtube dirrectly.
At first check path for $_FILES["file"]["name"].
I recommend to use code if you need get information about video. After you may parse data and get images/video etc.
public function getParseVideo($code = null){
$key = "your code";
if(!empty($code)){
$data = file_get_contents("https://www.googleapis.com/youtube/v3/videos? key=".$key."&part=snippet&id=".$code);
echo $json = json_decode($data);
}
}
How can I prepare a dynamic image created by GD for upload?
I created a php script to create dynamic images based on the userid (EX: www.mywebsite.com/image/124.png <== that should show the user 124 info)
Now I need to upload it to Facebook with this script :
$photo_details = array(
'message'=> $message
);
$file = "$_GET[id].png";
$photo_details['image'] = '#/home/username/public_html/image/' . $file;
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
When I use the upload script that way I get this error:
Fatal error: Uncaught CurlException: 26: failed creating formpost data
But If I uploaded 124.png to /image/ directory and and tried the same code again with using the ID 124 it works just fine. After a long research I came to conclusion the problem relay in the dynamic part since it works just fine with static images. How can I solve this problem?
Thank you so much for all the help.
Looks like the script tries to read the file directly from the filesystem instead of running the image generating script. You can solve this by setting $photo_details['image'] = 'http://www.mywebsite.com/image/'.$file; if Facebook class allows this kind of file opening.
I'm writing a web app that at one point allows a user to upload a photo to a flickr account (mine). I want to do this without saving the intermediate image on the server my web app is on.
What I've got so far is a page which implements phpFlickr and accepts a POST from a simple html form. I use $_FILES['file']['tmp_name'] as the path for phpFlickr to use. Here's the code:
<?php
require_once("phpFlickr.php");
$f = new phpFlickr("apikey", "secret", true);
$_SESSION['phpFlickr_auth_redirect'] = "post_upload.php";
$myPerms = $f->auth("write");
$token = $f->auth_checkToken();
$phid = $f->sync_upload($_FILES['file']['tmp_name']);
echo "Uploading Photo..." . $phid;
?>
I'm guessing that the tmp file is being lost because of the redirect that happens when $f->auth("write") is called, but I don't know. Is there a way to preserve it? Is there any way to do this without saving the file to the server?
Answer: There is No way to directly upload a file to Flickr without saving it as an intermediate file.
I've moved on to using move_uploaded_file() followed by a flickr API call, and its working perfectly.
I've also managed to get it to play nice with the excellent Jquery Uploadify, which lets me send multiple files to it in one go.