posting message on Facebook wall via flash/ActionScript - actionscript-3

I am creating a game that needs to be integrated with Facebook. The game is done and once the user complets that game it adds the button that send score to the Facebook wall of the user.
I have downloaded the Facebook api for flash and is able to connect to the user and get its id. But I don't know what command to use to post the score or message on users wall via swf.
Below is the basic codes...
import com.facebook.data.users.GetInfoData;
import com.facebook.utils.FacebookSessionUtil;
import com.facebook.data.users.FacebookUser;
import com.facebook.data.users.GetInfoFieldValues;
import com.facebook.data.friends.GetFriendsData;
import com.facebook.commands.users.GetInfo;
import com.facebook.commands.friends.*;
import com.facebook.net.FacebookCall;
import com.facebook.events.FacebookEvent;
import com.facebook.Facebook;
var fbook:Facebook; // Creating variable for facebook instance
var session:FacebookSessionUtil; //a utility for flash session is created
session = new FacebookSessionUtil("myAPPIT", "KEY", loaderInfo);// initializing the session
session.addEventListener(FacebookEvent.CONNECT, onFacebookConnect, false, 0, true);// checking if the face book is connected
fbook = session.facebook; // fbook holds the facebook instance as a property
fbook.login(true); // connected to the facebook
login_btn.addEventListener(MouseEvent.CLICK, connectToFB);
function connectToFB(e:Event):void
{
session.validateLogin();
}
function onFacebookConnect(e:FacebookEvent):void
{
trace("Is Facebook connected: " + fbook.is_connected);
var call:FacebookCall = fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);
}
function onGetInfo(e:FacebookEvent):void
{
var user = (e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
trace("Hello, " + user.first_name + " " + user.last_name);
}

you need this function
http://developers.facebook.com/docs/reference/rest/stream.publish
quick example could be find here:
http://novacoders.blogspot.com/2010/02/publish-post-to-facebook-wall-news.html

Related

Generating an alert message in katalon recorder

Is there any way I can generate custom popup message for browser. For example after successfully login I want to generate a custom browser popup message like “Login successfully”.
An example with login to katalon site:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import java.awt.Frame
import javax.swing.JOptionPane
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser('')
WebUI.navigateToUrl("https://www.katalon.com/sign-in/")
WebUI.waitForPageLoad(60)
WebUI.click(findTestObject('user_email'))
WebUI.setText(findTestObject('user_email'), "YOUR VALID USEREMAIL HERE")
WebUI.click(findTestObject('user_pass'))
WebUI.setText(findTestObject('user_pass'), "YOUR VALID PASSWORD HERE")
WebUI.click(findTestObject('login-btn'))
WebUI.waitForPageLoad(60)
Boolean loginSuccessFul = WebUI.verifyElementPresent(findTestObject('signOutButton'), 10)
if (loginSuccessFul) {
JOptionPane.showMessageDialog(new Frame('Login result'),
"Login successful.")
}
Maybe see more to java.awt and javax.swing at https://www.tutorialspoint.com/java/index.htm

Mailto works in Flash Pro but not when Published

Code is working when testing in Adobe Flash Pro as expected (email application opens and includes subject, name, id, supervisor, score), however whenever I publish and open in either FireFox, IE, or just open the swf player, the email client will open but with all the fields missing including the subject... I love how it works in Flash, and the simplicity of not having to have a server side php, but its not working as expected...
stop();
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLRequestMethod;
import flash.net.URLLoader;
// Variables
nameout_txt.text = names;
idout_txt.text = id;
supervisorout_txt.text = supervisor;
score.text = myscore+"";
//Email
var Email:URLRequest = new URLRequest
("mailto:ra#email.org" + "?subject=WOE Certificate" + " " + names + "&body=" + "Name: " + names + "\nEID: "
+id + "\nSupervisor Name: "+ supervisor + "\nScore: " + myscore);
emailbtn.addEventListener(MouseEvent.CLICK,emailCert);
function emailCert(event:MouseEvent):void {
navigateToURL(Email," _blank" ) ;
}
//Array to hold a list of the weekdays.
var weekdays:Array = new Array ("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
//Array to hold a list of the months.
var months:Array = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug", "Sep", "Oct","Nov","Dec");
//Adds an event listener to the dymanic text field.
the_date_txt.addEventListener(Event.ENTER_FRAME,showDate);
function showDate(event:Event):void {
//Create a new instance of the date class.
var myDate:Date = new Date();
//Retrieve the day, month and year from the date class.
var theDay=weekdays[myDate.getDay()];
var theMonth=months[myDate.getMonth()];
var theDate=myDate.getDate();
var theYear=myDate.getFullYear();
//Display the date in the dynamic text field.
the_date_txt.text=theDay+", "+theMonth+" "+theDate+", "+theYear;
}
/* Printing... */
/* Button */
print_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_3);
function fl_ClickToGoToAndPlayFromFrame_3(event:MouseEvent):void
{
gotoAndPlay(14);
}
trace(myscore)
Working Correctly
Not working
That is a security constraint on Flash Player and you have multiple options:
If you want to run the swf file locally you can add an exception in the Global Security Settings Panel
On Windows, export an .exe projector file using Flash Player.exe
Use a local webserver (like XAMP) and load the file from http://localhost instead of using the file:/// path (or simply upload the .swf file to a website and access if from there)
Publish your file for AIR instead of Flash Player
For option 1, you would need to add this exception for every computer you plan to run this .swf locally, therefore option 2 would make more sense.
Option 3 should also be simple enough.
Option 4 may be overkill, unless you need access to nicer native functionalities (like file system access, saving settings, custom icon, minimizing app to systray and potentially publishing to IOS/Android/etc.)

Flex HttpService authorization to obtain xml feed

im trying to obtain a xml feed from my cpanel though API. I have tried several methods (see below) to pass the authorization to obtain the xml feed.
In my browser i can get the feed through the following way:
http://user:pass#domain.com:2086/xml-api/listaccts?
The feed example from the server:
<listaccts>
<acct>
<disklimit>2500M</disklimit>
<diskused>56M</diskused>
<domain>domain.com</domain>
<email>dot#domain.com</email>
<ip>xx.xx.xx.xx</ip>
<max_defer_fail_percentage>unlimited</max_defer_fail_percentage>
<max_email_per_hour>unlimited</max_email_per_hour>
<maxaddons>*unknown*</maxaddons>
<maxftp>5</maxftp>
<maxlst>*unknown*</maxlst>
<maxparked>*unknown*</maxparked>
<maxpop>25</maxpop>
<maxsql>1</maxsql>
<maxsub>5</maxsub>
<min_defer_fail_to_trigger_protection>5</min_defer_fail_to_trigger_protection>
<owner>root</owner>
<partition>home</partition>
<plan>Basic</plan>
<shell>/usr/local/cpanel/bin/noshell</shell>
<startdate>13 Feb 17 07:05</startdate>
<suspended>0</suspended>
<suspendreason>not suspended</suspendreason>
<suspendtime/>
<theme>x3</theme>
<unix_startdate>1361109935</unix_startdate>
<user>xxxxxxxx</user>
</acct>
</listaccts>
My Application script:
<s:HTTPService id="clientList" method="GET" resultFormat="e4x"/>
In Scripts:
[Bindable]
private var clientInfo:Object = new Object();
private function clients(event:Event):void{
clientList.url = 'http://' +loginUsername.text
clientList.url += ':' + loginPassword.text
clientList.url += '#' + loginServer.text;
clientList.url += ':2086/xml-api/listaccts?';
clientList.addEventListener("result", clientResult);
clientList.addEventListener("fault", clientFault);
clientList.send();
CursorManager.setBusyCursor();
}
public function clientResult(event:ResultEvent):void {
clientInfo = clientList.lastResult.acct;
CursorManager.removeBusyCursor();
}
public function clientFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultString;
Alert.show("Unable to obtain client list","Error");
CursorManager.removeBusyCursor();
}
What am i doing wrong, i keep getting the error (Unable to obtain client list), i think i could be trying the authentication way i use.
Don't concatenate a string to add your username and password.
Call this as a WebService and use setCredentials.

How do I place a "Share to Facebook" Button in my Native Android App Built with Air for Android in Flash CS5.5?

I am new to this but we have created a new Android Native App using Air for Android in Flash CS 5.5. We have a working App and want to on the last screen, add a "Share to Facebook" button that will share the user's results to their Facebook wall / timeline. I have searched and searched but all I can find is either written in Java, not Actionscript 3, or is to update a status directly from the app. We only want to send a predefined snippet (User Results) from our app. Can someone please point me in the right direction??
There's an API for this, with variants for AIR desktop, AIR mobile, and web applications. It began life being officially supported by both Facebook and Adobe, although I'm not sure if it still is:
http://code.google.com/p/facebook-actionscript-api/
There is plenty of documentation on how to use it. You need to create an app on facebook, just so you can identify yourself properly. Add the facebook developers app to your FB account and then see here:
https://developers.facebook.com/
The basics of a share to wall call will look something like this:
import com.facebook.graph.data.FacebookAuthResponse;
import com.facebook.graph.Facebook;
function initializeFacebook()
{
Facebook.init("YOUR APP ID", onFacebookInit);
}
var interval:int = -1;
function onFacebookInit(success:Object, fail:Object):void
{
if (success)
{
post();
}
else
{
var opts:Object = { scope:"publish_stream" };
Facebook.login(null, opts);
// In theory you should get a post back when logged in.
// In practice this often fails, and it's better to poll for an access token.
interval = setInterval(pollForLoggedIn, 500);
}
}
function pollForLoggedIn():void
{
if (Facebook.getAuthResponse().accessToken)
{
clearInterval(interval);
post();
}
}
function post():void
{
var auth:FacebookAuthResponse = Facebook.getAuthResponse();
var token:String = auth.accessToken;
var user:String = auth.uid;
var values:Object =
{
access_token: token,
name: "TITLE OF YOUR POST",
picture: "OPTIONAL THUMBNAIL PATH",
link:"OPTIONAL LINK",
description: "OPTIONAL APP DESCRIPTION",
message: "BODY OF POST"
};
Facebook.api("/" + user + "/feed", handleSubmitFeed, values, URLRequestMethod.POST);
}
function handleSubmitFeed(success:Object, fail:Object):void
{
// Done.
}

Updating a flickr image upon user input

I am trying to integrate flickr into a weather app (yahoo weather api) that I've created and decided to start by leveraging flickrGrabber (http://blog.organa.ca/?p=19) as a starting point. I have both the weather app and flickrGrabber working however updating flickrGrabber after initial load is proving very challenging for me.
The initial image is being pulled via a search term set by a variable called flickrLocationName and I am able to update the variable value successfully upon entry of a new zip code however I can't seem to get flickrGrabber to unload & reload with the new value. My flickrGrabber code is on layer documentAS. The flickrGrabber class can be found within the Src folder and var flickrLocationName gets set from the WeatherObject class which can also found in the Src folder.
You can see what I mean by visiting this link:
http://truimage.biz/WAS400/WeatherApp/Deploy/weatherApp.html
Of course my source can be downloaded here:
http://truimage.biz/WAS400/weatherApp.zip
Any help would be very much appreciated. Here is some sample code:
import flickrGrabber;
var apiKey:String = "####"; //The working API key is in the zip file
var apiSecret:String = "####"; //The working API secret is in the zip file
var flickrLocationName:String;
var grabber:flickrGrabber;
function locationImage():void
{
grabber = new flickrGrabber(1024,600,apiKey,apiSecret,flickrLocationName,false);
grabber.addEventListener("imageReady", onLoadedImage);
grabber.addEventListener("flickrGrabberError", onErrorImage);
grabber.addEventListener("flickrConnectionReady", onFlickrReady);
function onFlickrReady(evt:Event):void
{
grabber.loadNextImage();
}
function onLoadedImage(evt:Event):void
{
addChildAt(grabber.image,0);
}
function onErrorImage(evt:ErrorEvent):void
{
trace("Report error: " + evt.text);
}
}
I'm pretty sure to change the image I need to remove the
addChildAt(grabber.image,0);
and rerun the function
locationImage();
But his is my best guess.