I'm very new to perl and am working with facebook authentication. This is the cpan facebook library
In it, during the callback i have the following code:
my $info = $fb->get(
'https://graph.facebook.com/v3.1/me?fields=birthday,email,name,id' # Facebook API URL
);
This is the response from $info->as_json;
{"email":"someemail\u0040email.com","name":"some user","id":"fbid"}
I've tried accessing the values using $info->email and $info->{email} and $info->{'email'} into my debugger but im getting null values. How do i obtain these values from the $info variable (hash?)
According to the documentation to which you linked, the proper usage is
my $data = $response>as_hash;
$data->{email}
Related
I can set a GET method in Slim to get data from my database but my problem is the POST method, i don't know how to use it correctly. I do some code like:
$app->post('/login',function() use ($app){
$inputs = json_decode($app->request()->getBody());
$result = json_encode($inputs);
return $result;
});
I wanna make a login function by POST method but this is just an example I want to show the data that have been sent in the body by json. I used Advanced Rest Client to test but the result is always "null".
I'm new to Rest and Slim Framework too. Thanks for any helpful idea !
using return doesn't do anything in terms of viewing the output within that route callback function. use print, print_r, echo, $app->response->setBody('Foo'), or $app->response->write('Foo')
in terms of the post, did you try using $data = $app->request()->post() to get your data?
Can I use Facebook::Graph to retrieve the number of likes without dealing with authorization tokens? The following code:
use Facebook::Graph;
my $fb = Facebook::Graph->new;
my $hashref = $fb->query
->request('https://graph.facebook.com/btaylor')
->as_hashref;
produces the following error:
Unable to create sub named ""
I'm not a real perl coder so I may be way off.
http://search.cpan.org/~rizen/Facebook-Graph-1.0501/lib/Facebook/Graph.pm
You can. Your problem is that btaylor is a regular facebook user and users cannot be liked. For objects that can be liked you can query for a list of likes following the example below.
https://graph.facebook.com/thagroggs
I would like to know how do I insert solvemedia captcha with my script. I did install the module from their site (https://portal.solvemedia.com/media/download/WWW-SolveMedia-1.1.tar.gz) but don't know where to add this (their instructions):
Once the plugin is installed, you can start making calls to the Solve Media API.
Display the Widget
To display the Solve Media widget on one of your forms, instantiate the SolveMedia class, supplying it with your API keys. Then call the get_html function. You can find your API keys at My account:
use WWW::SolveMedia;
my $c = WWW::SolveMedia->new( 'my challenge key',
'my verification key',
'my hash key' );
# output widget
print $c->get_html();
Process Answer
You can check the user's response by calling SolveMedia.check_answer(...).
# check answer
my $result = $c->check_answer( $ENV{REMOTE_ADDR}, $challenge, $response );
if( $result->{is_valid} ){
print "Yay!";
}else{
print "Dang it :-(\n";
print "Error: ".$result->{error};
}
And this is where I get stuck, cos I don't have a clue how/where to insert that code. If anyone of you is willing to help, please respond. I'm willing to pay a few bucks.
You create the new object, and either save the results of get_html into a variable which you then stick into some web page, or you print it inline.
You put the Perl code in the subroutines that generate the pages that you want the captcha to appear.
and you put the call to process in the code that process the submission of the form on the page that you printed the captcha into.
we are using Perl and cpan Modul FeedPP to parse RSS Feeds.
The Perl script runs trough the different items of the RSS Feeds and save the link to the database, liket his:
my $response = $ua->get($url);
if ($response->is_success) {
my $feed = XML::FeedPP->new( $response->content, -type => 'string' );
foreach my $item ( $feed->get_item() ) {
my $link = $item->link();
[...]
$url contains the URL to an RSS Feed, like http://my.domain/RSS/feeds.xml
in this case, $item->link() will contain links to the RSS article, like http://my.domain/topic/myarticle.html
The Problem is, some webservers (which provides the RSS feeds) does an HTTP refer in order to add an session ID to the URL, like this: http://my.domain/RSS/feeds.xml;jsessionid=4C989B1DB91D706C3E46B6E30427D5CD.
The strange think is, that feedPP seams to add this session-ID to the link of every item. So $item->link() contain links to the RSS article, like http://my.domain/topic/myarticle.html;jsessionid=4C989B1DB91D706C3E46B6E30427D5CD
Even if the original link does not contain an session ID.
Is there a way to turn of that behavior of feedPP??
Thank you for any kind of help.
I took a look through http://metacpan.org/pod/XML::FeedPP but didn't see any way to turn have the link() method trim those session IDs for you. (I'm using XML::FeedPP in one of my scripts and the site I happen to be parsing doesn't use session IDs.)
So I think the answer is no, not currently. You could try contacting the author or filing a bug.
IMHO, the behavior is correct: uri components which follow a semi-colon are defined part of the path (configuration parameter for interpretation), so when the uri is used to make a relative url into an absolute uri it needs to be copied as well.
You expect compatible behavior with '&' parameters, but they are not equal.
https://rt.cpan.org/Ticket/Display.html?id=73895
Yelp API V2.0 have problem to get response .when i send request in yelp API V2.0 with all authentication key and token , i get error missing parameter . if any one have idea regarding Yelp help me
If you get this error:
{"error":{"text":"One or more parameters are invalid in
request","id":"INVALID_PARAMETER","field":"oauth_timestamp"}}
then your timestamp is sometime in the past. You can resolve this by dynamically getting the current time or by setting the timestamp parameter to some arbitrary value in the future.
You got that error because you are not using the keys themselves "The OAuth credentials are invalid" ...oauth_consumer_key=mykey&auth_consumer_secret=mykey...
it should look like this ...oauth_consumer_key=XXXXXXXXXXXXXXXXXXXXX&auth_consumer_secret=XXXXXXXXXXXXXXXXXXXXX...
Have a look at their github https://github.com/Yelp/yelp-api/tree/master/v2/ they have some examples that might help for example on the PHP
// Set your keys here
$consumer_key = "";
$consumer_secret = "";
$token = "";
$token_secret = "";
you should set your keys in between the quotes $consumer_key = "XXXXXXXXXXXXXXXXXXXXX";