How to publish youtube video to wall of facebook - facebook-graph-api

I wanted to publish youtube video to wall of facebook.Does any one know ,how to do that.If yes,let me know that.

well i use involver
http://www.involver.com/
to publish vids from youtube to my fb page but it doesn't work on personal facebook wall
you can press the share button under the youtube video and share it to facebook and it will be published on your wall, you can also copy the link and past it on facebook wall

Basically, this page is a very good start. It explains how to publish using GraphAPI.
You'll need an app ( this page ) and you'll need to :
Get the app linked to your account with permissions ( publish_stream for publishing on a User's wall ) echoing some javascript to reload the page to facebook with a redirect_uri to your app or your web page.
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&scope=publish_stream";
echo("<script>top.location.href='" . $dialog_url . "'</script>");
Get the token via
$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$access_token = file_get_contents($token_url);
Then you'll need to send a post with enctype="multipart/form-data" to https://graph-video.facebook.com/me/videos? with the following elements:
token
description
title
file ( as a multipart upload stream )
using a form like:
<form enctype="multipart/form-data" action="<?php echo $my_url ?>" method="POST">
<input type="file" name="file>
<input type="submit">
</form>
The main drawback is that after you successfully uploaded ( or not ) you'll have a plain json with either the error code or the Object Graph ID of the newly created element. I haven't sorted out yet how to overcome that. I'll try CURL out.

Related

How to upload image using rest web services in symfony

I am trying upload image using rest web service in my symfony application. I have tried the following code but it is throwing the error undefined index photo. I want to know what is the right way to do it.
I have followed how to send / get files via web-services in php but it didn't worked.
Here is the my html file with which am hitting the application url:
<form action="http://localhost/superbApp/web/app_dev.php/upload" enctype='multipart/form-data' method="POST">
<input type="file" name="photo" ></br>
<input type="submit" name="submit" value="Upload">
</form>
And my controller method is like:
public function uploadAction(){
$request = $this->getRequest(); /*** get the request method ****/
$RequestMethod = $request->getMethod();
$uploads_dir = '/uploads';
foreach ($_FILES["photo"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["photo"]["tmp_name"][$key];
$name = $_FILES["photo"]["name"][$key];
move_uploaded_file($tmp_name, $uploads_dir."/".$name);
}
}
}
If you are using Symfony, you should use Symfony forms to do this. In your example, you put an URL which is pointing to app_dev.php, but that url doesn't work in production mode. In the Symfony cookbook there is an article explaining how upload files, which you should read:
http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html
When you have done this, you can upload images via Rest WebService using the route specified for your action, specifying the Content-Type to multipart/form-data, and the name of the field which you add the image would be something like this package_yourbundle_yourformtype[file].

User redirect with POST in iframe

I am building one of my first MVC 4 applications and I need some help with redirecting users.
I have a windows form application where I use a AxSHDocVw.AxWebBrowser to redirect the user to a specific URL , a SOAP web service to be precise, aswell as sending HTTP POST and HEADER data aswell.
This is done like so:
oHeaders = "Content-Type: application/x-www-form-urlencoded" + "\n" + "\r";
sPostData = "ExchangeSessionID=" + SessionID;
oPostData = ASCIIEncoding.ASCII.GetBytes(sPostData);
axWebBrowser2.Navigate2(ref oURL, ref o, ref o, ref oPostData, ref oHeaders);
I am looking to replicate this functionality in my MVC application, but am unsure of the how this can be done.
I was hoping to have this within an iframe, but can't find a way of sending the POST and HEADER data from this. This is what I have been trying so far:
Controller
ViewBag.URL = TempData["URL"];
ViewBag.SessionID = TempData["SessionID"];
ViewBag.FullURL = TempData["URL"] + "?ExchangeSessionID=" + TempData["SessionID"];
return View();
View
<iframe src="#ViewBag.FullURL" width="100%" height="500px"></iframe>
Basically I was trying to append the data to the end of the URL hoping this would work for the HTTP POST part. This is what I ended up with:
https://www.myurl.aspx?ExchangeSessionID=87689797
The user is being directed to the page, but the web service is giving me an error ( which tells me it is now receiving the POST data).
Can some please help me to try and fix this, or even give me advice on how to go about this another way. Like I said, I'm fairly new to MVC applications and I'm not entirely sure what I'm tryin to do is even possible.
Any help is appreciated. Thanks
I've decided to answer this question myself incase anybody is looking to do something similar in the future.
The first step was to create my iframe:
<iframe name="myframe" src="" width="100%" height="700px"></iframe>
Next I want to create a form with a button which, when pressed, will post the data to the url while targeting the iFrame (Note the target attribute of the form):
<form action="#ViewBag.URL" method="post" target="myframe">
<input type="hidden" name="ExchangeSessionID" value="#ViewBag.SessionID" />
<input type="submit" value="Submit" />
</form>
So what happens is, when the button is pressed, the form posts the ExchangeSessionID to the target URL and then the page response is displayed inside the iFrame.

FB.ui apprequests is not working on iFrame Tab

I'm using facebook JS api and
FB.ui({
method: 'apprequests',
message: 'You should learn more about this awesome game.',
data: 'tracking information for the user'
});
but its not working on tab , the pop-up stats to load and then automatically become hidden .
http://developers.facebook.com/docs/reference/dialogs/
You can only use iframe in facebook apps, probably also on tab pages.

Add to cart button in osCommerce keeps redirecting back to product page

I have an ebook item in osCommerce that includes product attributes. When I click the Add to Cart button from the index page it should go directly to the shopping_cart.php page. However, it only keeps redirecting the customer back to the product_info.php page.
Why is it doing that?
If the product has attributes osCommerce expects that you select one of them before adding the product to the cart. That's why it is redirecting you to the product detail page.
try this code:
find if ($col === 0) {$new_prods_content .= '';} (around line 29)
below add this code:
$new_prods_content .= '<td width="30%" align="center" valign="top">
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .
$new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES .
$new_products['products_image'], $new_products['products_name'],
SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' .
tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .
$new_products['products_id']) . '">' . $new_products['products_name'] .
'</a><br />' . $currencies->display_price($new_products['products_price'],
tep_get_tax_rate($new_products['products_tax_class_id'])) .
'&nbsp&nbsp&nbsp' . tep_draw_button(IMAGE_BUTTON_IN_CART, null ,
tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) .
'action=buy_now&products_id=' . $new_products['products_id'])) .'</td>';
i have added this code for new products in index.php page and when customer clicks add to cart button, it will add the item to cart and show shopping_cart.php page.

sending facebook friend invitation using new javascript SDK shows 403 forbidden page but the invitation is sent successfully

In my django website, I am using the new facebook javascript SDK to allow my users to send friend invitation to their facebook friends.
But When users send the website invitation(after login & selecting friends from the facebook popup), the invitation is send successfully but users see a "403 Forbidden - Cross Site Request Forgery detected. Request aborted " page ( at the same url from which the invitation was sent). How to overcome this csrf validation.
The javascript code for the invitation( after loading the facebook SDK ):
<script>
function invitePopup() {
FB.login(function(response) {
if (response.session) {
// user successfully logged in
FB.ui({
method:'fbml.dialog',
fbml: (
'<fb:request-form action="http://{{site.domain}}{% url account_view %}" method="post" invite="true" type="{{ site.name }}" ' +
'content="help the world by spreading good ideas. Join the move! <fb:req-choice url=\'http://{{site.domain}}{% url facebook_login %}?facebook_invitation=1\' label=\'Accept\' />" >' +
'<fb:multi-friend-selector showborder="false" bypass="cancel" actiontext="Invite your friends to join {{ site.name }}" /> '+
'</fb:request-form>'
),
size: { width:640, height:480}, width:640, height:480
});
$(".FB_UI_Dialog").css('width', $(window).width()*0.8); // 80% of window width
} else {
// user cancelled login
}
});
}
</script>
and the triggering part:
Invite your Facebook friends to join {{ site.name }}
There is a workaround I've tried i.e. using csrf_exempt decorator for the view. But I don't want to use it because I'm using more forms in that view which needs csrf protection.
you can include crsf_token like this:
FB.ui({
method:'fbml.dialog',
fbml: (
'<fb:request-form action="http://{{site.domain}}{% url account_view %}" method="post" invite="true" type="{{ site.name }}" ' +
'content="help the world by spreading good ideas. Join the move! <fb:req-choice url=\'http://{{site.domain}}{% url facebook_login %}?facebook_invitation=1\' label=\'Accept\' />" >'
+ "{% csrf_token %}"+
'<fb:multi-friend-selector showborder="false" bypass="cancel" actiontext="Invite your friends to join {{ site.name }}" /> '+
'</fb:request-form>'
),
size: { width:640, height:480}, width:640, height:480
});
Works perfect for me.
Hf