Sponsored Content
Top Forums Shell Programming and Scripting Malformed session key while using Facebook API Post 302776603 by pandeesh on Wednesday 6th of March 2013 02:26:32 PM
Old 03-06-2013
Malformed session key while using Facebook API

Hi,

I am doing some experiments with facebook API and unable to update the status using the API.
My code is as follow as:
Code:
use WWW::Facebook::API;
use JSON::Any;

my $query=new CGI;
my $j = JSON::Any->new;
my $api_key="#MY API KEY#";
my $secret="#MY SECRET KEY#";
my $fb = WWW::Facebook::API->new( 
    desktop => 0, 
    api_key => $api_key, 
    secret  => $secret, 
    session_key => $query->cookie($api_key.'_session_key'),
    session_expires => $query->cookie($api_key.'_expires'), 
    session_uid => $query->cookie($api_key.'_user')
);

my $res = $fb->stream->publish( 
    message => 'Test message', 
    attachment => $j->objToJson( 
        { name => 'Foo bar baz', 
          href => 'http://www.google.com/', 
          description => "this is a thing" 
       } ), 
    action_links =>  $j->objToJson( 
      [ { text => 'action link text', 
          href => 'http://www.foobar.com/' 
      } ] ) 
);

In the original code, i replaced with original api and secret keys .
But i am receiving the below error an di don't have any clue how to fix this.

Code:
Odd number of elements in hash assignment at C:/Dwimperl/perl/site/lib/WWW/Facebook/API.pm line 164.
Error during REST stream.publish call:
params = 
    action_links:[{"href":"http://www.foobar.com/","text":"action link text"}]
    api_key:#api_key#
    attachment:{"href":"http://www.google.com/","name":"Foo bar baz","description":"this is a thing"}
    format:JSON
    message:Test message
    method:facebook.stream.publish
    session_key:session_expires
    v:1.0
response =
{"error_code":102,"error_msg":"Session key is malformed.","request_args":[{"key":"action_links","value":"[{\"href\":\"http:\/\/www.foobar.com\/\",\"text\":\"action link text\"}]"},{"key":"api_key","value":"#api_key#"},{"key":"attachment","value":"{\"href\":\"http:\/\/www.google.com\/\",\"name\":\"Foo bar baz\",\"description\":\"this is a thing\"}"},{"key":"format","value":"JSON"},{"key":"message","value":"Test message"},{"key":"method","value":"facebook.stream.publish"},{"key":"session_key","value":"session_expires"},{"key":"v","value":"1.0"},{"key":"sig","value":"fa1423663792249368fd00e9f102b992"}]}

Any thoughts on this.

Thanks in Advance!

--Pandeesh
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sqlplus session being able to see unix variables session within a script

Hi there. How do I make the DB connection see the parameter variables passed to the unix script ? The code snippet below isn't working properly. sqlplus << EOF user1@db1/pass1 BEGIN PACKAGE1.perform_updates($1,$2,$3); END; EOF Thanks in advance, Abrahao. (2 Replies)
Discussion started by: 435 Gavea
2 Replies

2. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

3. Solaris

Sendmail 8.13.8 malformed address

Sending email produces malformed address error. The domain name appears as the active directory name which is not a valid Internet domain thus the malfomred address error. I have: divert(0)dnl VERSIONID(`@(#)sendmail.mc 1.11 (Sun) 06/21/04') OSTYPE(`solaris8')dnl... (0 Replies)
Discussion started by: crowman
0 Replies

4. Shell Programming and Scripting

Need Suggestions to improve Perl script for checking malformed braces/brackets

Hi all, I've written a Perl script below that check and report for malformed braces. I have a UNIX ksh version and it took a couple of minutes to run on a 10000+ lines. With the Perl version it only took about 20 seconds so that is enough incentive for me to go Perl not to mention that I need... (1 Reply)
Discussion started by: newbie_01
1 Replies

5. AIX

[Tip] /dev filling because of malformed IBM script

There is some IBM script out there, which contains a hidden syntax error. I am not sure which script it is (we are still investigating), but most of my HACMP systems (up to version 6.1) showed the symptom and i suspect the source to be in HACMP. Have a look at your system. Probably someone at... (1 Reply)
Discussion started by: bakunin
1 Replies

6. Shell Programming and Scripting

Need to run an API from a script and extract fields from output of API

Hi, I need to call an API (GetUsageDetails)from inside a shell script which takes an input argument acct_nbr. The output of API will be like : <usageAccum accumId="450" accumCaptn="PM_125" inclUnits="1410.00" inclUnitsUsed="744.00" shared="true" pooled="false" prorated="false"... (1 Reply)
Discussion started by: rkrish
1 Replies

7. UNIX for Dummies Questions & Answers

Sudo apt-get update fail: Malformed line 59

I am trying to update/add a repository. Whenever I try to do a sudo apt-get update I get the message: E: Malformed line 59 in source list /etc/apt/sources.list (dist parse) E: The list of sources could not be read. and when I do: gksudo gedit /etc/apt/sources.list I see... (1 Reply)
Discussion started by: kayak
1 Replies

8. UNIX for Dummies Questions & Answers

Remote Desktop Session Prints Warning Message Everytime I Hit One Specific Key

Hello All, My question has to do with a Remote Desktop Session going from my Linux HOST to a Windows GUEST. Linux OS: OpenSuSE 11.4 i586 Windows OS: Windows Server 2003 For some reason after I have run rdekstop to connect to the Windows Guest, whenever I click on the Shift key I get the... (0 Replies)
Discussion started by: mrm5102
0 Replies
FLICKR_UPLOAD(1p)					User Contributed Perl Documentation					 FLICKR_UPLOAD(1p)

NAME
flickr_upload - Upload photos to "flickr.com" SYNOPSIS
flickr_upload [--auth] --auth_token <auth_token> [--title <title>] [--description description] [--public <0|1>] [--friend <0|1>] [--family <0|1>] [--tag <tag>] [--option key=value] [--progress] <photos...> DESCRIPTION
Batch image uploader for the Flickr.com service. flickr_upload may also be useful for generating authentication tokens against other API keys/secrets (i.e. for embedding in scripts). OPTIONS
--auth The "--auth" flag will cause flickr_upload to generate an authentication token against it's API key and secret (or, if you want, your own specific key and secret). This process requires the caller to have a browser handy so they can cut and paste a url. The resulting token should be kept somewhere like "~/.flickrrc" since it's necessary for actually uploading images. --auth_token <auth_token> Authentication token. You must get an authentication token using "--auth" before you can upload images. See the EXAMPLES section. --title <title> Title to use on all the images. Optional. --description <description> Description to use on all the images. Optional. --public <0|1> Override the default "is_public" access control. Optional. --friend <0|1> Override the default "is_friend" access control. Optional. --family <0|1> Override the default "is_family" access control. Optional. --tag <tag> Images are tagged with "tag". Multiple "--tag" options can be given, or you can just put them all into a single space-separated list. If you want to define a tag with spaces, the quotes have to be part of the tag itself. The following works in bash: flickr_upload --tag='"tag one"' --tag='"tag two"' image.jpg --option key=value Flickr periodically adds new features to the uploading API, and these are almost always implemented as new key/value pairs. Rather than waiting for a new Flickr::Upload release, you can specify any of the upload API's optional arguments using "--option". flick_upload --option content_type=1 --tag='cats' two_cats.jpg You may also use "--option" rather than flickr_upload's command-line options: flickr_upload --option is_public=1 --option title='cats' two_cats.jpg While Flickr may add new options at any time (see <http://flickr.com/services/api/upload.api.html> for the most up-to-date list), currently known options include: --option safety_level=<1|2|3> Override the default "safety_level" notation. Set to 1 for Safe, 2 for Moderate, or 3 for Restricted. Refer to <http://www.flickr.com/help/filters/>. --option content_type=<1|2|3> Override the default "content_type" notation. Set to 1 for Photo, 2 for Screenshot, or 3 for Art/Illustration. Refer to <http://www.flickr.com/help/filters/>. --option hidden=<1|2> Override the default "hidden" notation. Set to 1 to keep the photo in global search results, 2 to hide from public earches. Note that options unknown to Flickr will result in undefined behaviour. --check Checks the authentication token via the flickr.auth.checkToken API call. This can be used to verify API keys and credentials without trying to upload an image. The output is the raw results of the API call. --progress Display a progress bar for each upload with Term::ProgressBar. That optional module will have to be installed on the system. --key <api_key> --secret <secret> Your own API key and secret. This is useful if you want to use flickr_upload in auth mode as a token generator. You need both "key" and "secret". Both "key" and "secret" can be placed in "~/.flickrrc", allowing to mix flickr_upload with your own scripts using the same API key and authentication token. Getting your own API key and secret is encouraged if you're tying flickr_upload to some automated process. Note that if you do get an authentication token against your own API key and secret, you'll need to specify the key and secret along with the token when uploading images. The default flickr_upload API key and token won't work in that case. <photos...> List of photos to upload. Uploading stops as soon as a failure is detected during the upload. The script exit code will indicate the number of images on the command line that were not uploaded. For each uploaded image, a Flickr URL will be generated. flickr_upload uses asynchronous uploading so while the image is usually transferred fairly quickly, it might take a while before it's actually available to users. flickr_upload will wait around for that to complete, but be aware that delays of upwards of thirty minutes have (rarely) been know to occur. EXAMPLES
First, you need to get an authentication token. This is a requirement driven by how Flickr manages third-party applications: cpb@earth:~$ flickr_upload --auth 1. Enter the following URL into your browser http://flickr.com/services/auth?api_sig=<...>&frob=<...>&perms=write&api_key=<...> 2. Follow the instructions on the web page 3. Hit <Enter> when finished. Your authentication token for this application is <token> Unless you like typing long numbers on the command-line, you should keep the "<token"> somewhere handy, like a configuration file: echo auth_token=<token> >~/.flickrrc Uploading a bunch of images is then as easy as: flickr_upload --tag 'dog' 'kernel in a window.jpg' 'sad in sunbeam.jpg' CONFIGURATION
To avoid having to remember authentication tokens and such (or have them show up in the process table listings), default values will be read from "$HOME/.flickrrc" if it exists. Any field defined there can, of course, be overridden on the command line. For example: # my config at $HOME/.flickrrc auth_token=334455 is_public=0 is_friend=1 is_family=1 Note, however, that these defaults override the defaults you've assigned in your Flickr profile. You may want to do all that stuff in one place. BUGS
Error handling could be better. AUTHOR
Christophe Beauregard, cpb@cpan.org. SEE ALSO
flickr.com Flickr::Upload <http://flickr.com/services/api/> <http://www.flickr.com/help/filters/> perl v5.10.0 2008-10-27 FLICKR_UPLOAD(1p)
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy