I am using PHP SDK to upload videos to my DailyMotion channel, but i don't understand how this work.
I do this:
// Temporarily upload a file on Dailymotion' servers
// This does not create a video, it only offers you a public URL to work with.
$url = $api->uploadFile($videoPath);
try {
// More fields may be mandatory in order to create a video.
// Please refer to the complete API reference for a list of all the required data.
$result = $api->post(
'/me/videos',
array(
'url' => $url,
'title' => $title,
'tags' => 'video,publish,api',
'published' => true,
'is_created_for_kids' => false
)
);
print_r($result);
} catch(\Exception $e) {
die('exception: ' . $e->getMessage());
}
$api->logout();
When the video is uploaded, i keep getting a message saying "Publication in progress" for days (a week now and still getting the same message).
Although i can see/watch the video just fine if i used the account it belongs to.
I'm using 'GRANT_TYPE_PASSWORD' to upload the videos to my account.
I don't want my videos to be published in search results though, i just want my app users to be able to watch them embeded.
Any help would be highly appreciated, thanks in Advance.
Related
Now I posting a single photo to wall like this:
$response = $facebook->api("/$group_id/photos", "POST", array(
'access_token=' => $access_token,
'message' => 'This is a test message',
'url' => 'http://d24w6bsrhbeh9d.cloudfront.net/photo/agydwb6_460s.jpg',
)
);
It works fine, but can I somehow post a multiple photos, something like this:
You can now publish multiple images in a single post to your feed or page:
For each photo in the story, upload it unpublished using the {user-id}/photos endpoint with the argument published=false.
You'll get an ID for each photo you upload like this:
{
"id": "10153677042736789"
}
Publish a multi-photo story using the {user-id}/feed endpoint and using the ids returned by uploading a photo
$response = $facebook->api("/me/feed", 'POST',
array(
'access_token=' => $access_token,
'message' => 'Testing multi-photo post!',
'attached_media[0]' => '{"media_fbid":"1002088839996"}',
'attached_media[1]' => '{"media_fbid":"1002088840149"}'
)
);
Source: Publishing a multi-photo story
You can make batch requests as mentioned here: https://stackoverflow.com/a/11025457/1343690
But its simple to loop through your images and publish them directly.
foreach($photos as $photo)
{
//publish photo
}
Edit: (regarding grouping of photos on wall)
This grouping is done by facebook automatically if some photos are uploaded into the same album.
Currently you cannot create an album in a group via Graph API - it is not supported (as of now), see this bug.
But you can do this - create an album manually, then get the album_id by-
\GET /{group-id}/albums, then use the the code with album_id instead of group_id-
foreach($photos as $photo){
$facebook->api("/{album-id}/photos", "POST", array(
'access_token=' => $access_token,
'name' => 'This is a test message',
'url' => $photo
)
);
}
I've tested it, see the result-
Actually you can upload a multi story photo(I did it using Graph Api and PHP) but the problem comes if you need scheduled this post.Your post is schedule but also it shows on the page's feed.
P.S. I'm using Graph Api v2.9
PHP Code
$endpoint = "/".$page_id."/photos";
foreach ($multiple_photos as $file_url):
array_push($photos, $fb->request('POST',$endpoint,['url' =>$file_url,'published' => FALSE,]));
endforeach;
$uploaded_photos = $fb->sendBatchRequest($photos, $page_access_token);
foreach ($uploaded_photos as $photo):
array_push($data_post['attached_media'], '{"media_fbid":"'.$photo->getDecodedBody()['id'].'"}');
endforeach;
$data_post['message'] = $linkData['caption'];
$data_post['published'] = FALSE;
$data_post['scheduled_publish_time'] = $scheduled_publish_time;
$response = $fb->sendRequest('POST', "/".$page_id."/feed", $data_post, $page_access_token);
$post_id = $cresponse->getGraphNode()['id'];
You will need to upload each photo first with published state to false, and then use the ID's of the unpublished photos to the /me/feed endpoint to schedule the photo. The schedule needs to be within the 24 hours from the time the photos are uploaded as facebook deletes all unpublished photos in 24 hours.
Ref:
https://developers.facebook.com/docs/graph-api/photo-uploads/
There is no way to publish more than one photo in the same graph API call.
See documentation: https://developers.facebook.com/docs/graph-api/reference/user/photos
I have php code that posting in the wall of the user that use in my app. But in the post write
"post by _" (My app name).
Code:
$fql_info = $facebook->api($fql_query);
if($fql_info[0][offline_access] == 1)
{
$attachment = array(
'message' => "",
'name' => u("ghfhgfhfgh"),
'description' => u("fghgfhgfh"),
'link' => LINK,
'picture'=> "http://gfhgfhgfhfh"
);
$facebook->api('/'.$f[uid].'/feed', 'POST', $attachment);
$abc.=$f[uid]."\n";
echo $f[uid]."-".$fql_info[0][offline_access]."\n";
}
I want to know how I can to post but without my app name. User as poster itself, not the application has released it.
is it possible?
I guess it's not possible. The app name will appear in the post.
Sorry to say but i don't think this is possible . Facebook would not allow us to do that , it will always say Posted via : [Your APP name]
I have a Facebook App that allows users to upload pictures from my website to my Facebook page. I would like to know who uploaded the pictures and after some research I managed to get this following PHP code:
$args = array(
'message' => $fbme['name'].' will have a love marriage.',
'image' => '#' . realpath('./images/wall-e-and-eva1.jpg'),
);
$data = $facebook->api('/'.$uid.'/photos', 'post', $args);
My output is suppose to be on the lines of Adam Smith will have a love marriage unfortunately the only output I am getting is will have a love marriage.
How can I get the value of $fbme['name'] - can you give me a pratical example of code please?
Thanks.
You can use the graph api to fetch basic information (including name) of your authenticated users
try {
$fbme = $facebook->api('/'.$uid); // $fbme['name'] will be the user's name
// put rest of your code below
} catch (FacebookApiException $e) {
// handle errors
}
I'm trying to post a check-in in user's feed, using offline access. But I keep getting various errors, but if i try to post message/video/picture everything works great.
So here is my code:
public function postCheckIn()
{
$post=array(
'access_token'=> $this->token,
'message'=>'Test check-in!',
'place'=>'172822562765332',
'coordinates' => json_encode(array(
'latitude' => '55.772855818478',
'longitude' => '37.687225341797'
))
);
try
{
$res=$this->fb->api('/'.$this->uid.'/checkins', 'POST', $post);
}
catch(FacebookApiException $e)
{
$res=$e->getMessage();
}
return $res;
}
When I'm running this code, I get an exception:
Requires a valid Place Page ID
I check this place using https://developers.facebook.com/tools/explorer/, and it returns some valid info.
BTW, I have publish_checkins permission.
Do I always have to provide placeId, and coordinates? Can I provide one of this parameters?
And how to get it to work?
Thank you.
https://graph.facebook.com/172822562765332 doesn't have latitude longitude data
i suppose that's why
this is a snippet that work... your params looks correct to me
formPost->addField("message",message );
formPost->addField("place",place);
formPost->addField("coordinates",coordinates);
formPost->addField("tags",tags );
formPost->addField("application","{\"id\": \"204264309603362\",\"name\": \"mobile borg\"}");
qDebug()<<"FacebookGraph::post"<
QString feed=url+"me/checkins";
You can always use the publish_stream as this will get around any issues you are having with offline publishing.
http://developers.facebook.com/docs/reference/rest/stream.publish/
Hi I am using the graph API to post to the the wall of a friend.
However I do not want the post to be visible on any News Feeds
(the posting user, the friend being posted to, or anyone else).
How can I achieve this. Here is my wall post code:
function fb_post($to_uid,$acToken) {
$result = false;
global $fb;
$feed_dir = '/'.$to_uid.'/feed/';
$message_str = 'This is a message';
$msg_body = array('access_token' => $acToken,
'message' => $message_str,
'name' => 'Wall Post',
'caption' => "I posted to your wall",
'link' => 'http://www.wallpost.com',
'description' => 'Learn how to post to peoples walls',
'picture' => 'http://image.com/myimage.jpg',
'actions' => array(array('name' => 'Wall Post',
'link' => 'http://www.wallpost.com'))
);
try {
$result = $fb->api($feed_dir, 'post', $msg_body);
}
catch (Exception $e) {
echo "Not sent";
}
}
Thanks.
Short answer is no.
Facebook's recent lists and so on are a dynamic amalgamation of posts - a post can't be marked to opt-out of this, Facebook decides its relevancy and coverage.
A user may have their profile configured to so that postings of certain types/from certain applications are handled in a specific way, but there's nothing you can personally do about that - and I still don't think it encompasses options to hide posts from feeds, mainly just disallow them from their wall in the first place.
You can add 'privacy' => '{value: SELF}'. However, it work for users who are already in application. So friend of user who posting something to his friend's wall should be authorized in our application as well