AS3 Flash api not setting game category app score - acces token error - authentication

Hope it's not a very noobish question i'm asking :) -
I'm trying to set the score parameter for my app ( Game category app ) with the AS3 Flash API ( Which i see is a wrapper around JS Api ) but i keep getting the "(#15) This method must be called with an app access_token" error, i've also tried a test call with the Graph API Explorer and the result is the same.( with generated acces token of the app and copy/pasted acces token )
I've searched the permission tables and i've set both publish_actions and user_games_activity for the authentification process.
Getting works perfectly ( i can receive basic information without any problems also score information but it's just an empty array probably because it isn't set ) posting seems to be the culprit
I want to know if i'm doing something wrong ( something like there's an additional auth process necessary on my server side )
If you guys have any ideea please help this is becoming very frustrating
Thanks in advance :D

Finally found the solution.
Here is the correct AS3 code:
var data:Object = new Object();
data.score = 285;
data.access_token = APP_ACCESS_TOKEN;
var requestType:String = "POST";
Facebook.api( Facebook.getAuthResponse().uid + "/scores/" , handlePostScoreComplete, data, requestType);
You MUST get the app access token using PHP or some other client-side SDK, not the Javascript SDK because it needs the app secret.
So in PHP you must get the access token and then you can pass it to Flash:
<?php
$APPLICATION_ID = YOUR_APP_ID;
$APPLICATION_SECRET = YOUR_APP_SECRET;
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $APPLICATION_ID .
"&client_secret=" . $APPLICATION_SECRET .
"&grant_type=client_credentials";
$app_token = file_get_contents($token_url);
?>

Related

How to use shutterstock API to search and get photos in a simple way

I am making a site that allows users to search and send to print a shutterstock photo
Like this one:
https://wallprint.ee/
I am following the Shutterstock API documentation and trying to use this to connect, search and pick photos:
https://github.com/shutterstock/php-shutterstock-api
is this the best and easiest way to do it?!!
This is the way I am trying now:
require_once __DIR__ . '/vendor/autoload.php';
$clientId = '***';
$clientSecret = '****';
$client = new Shutterstock\Api\Client($clientId, $clientSecret);
var_dump($client);
// perform an image search for puppies
$client->get('images/search', array('query' => 'puppies'));
$imageResponse = $client->get('images', array('id' => array(1, 2, 3)));
if ($imageResponse->getStatusCode() != 200) {
// error handler
}
$images = $imageResponse->getBody()->jsonSerialize()['data'];
// etc
I expected:
Some kind of response with the content.
I got
Client error: GET https://api.shutterstock.com/v2/images?id=1&id=2&id=3 resulted in a 403 Forbidden response: {"message": "You do not have access to this route. Please contact api#shutterstock.com for more information"}
I read that since I use 'get'
I am told that a free APP can't do using get:
https://developers.shutterstock.com/documentation/authentication#accounts-and-limitations
I wrote about that already to api#shutterstock.com
But what options do I have to develop it in a simplest and painfree manner?
I'm Errol and I work on the API here at Shutterstock. Typically, you will receive this error because your app does not have access to call that route.
Unfortunately, there is no other options to achieve what wallprint is doing without having print partnership with Shutterstock. We want you to have access to the API endpoints you need that way developers like yourself can create awesome apps, however, it needs to be done in a way that doesn't violate Shutterstocks license or terms of service.
Should you have any questions or concerns about this, please drop us a message at api#shutterstock.com

Podio::authenticate_with_app($app_id, $app_token); is not working

My client has a site on 'ideacontainer.net/real_coffee/'. Now I guess he has accidentally deleted the app then recovered it. But from that time he is not able to access his site.
This is the code in his index file
require_once 'podio-php-master/PodioAPI.php';
$client_id = "some-client-id";
$client_secret = "3zLcr...";
$app_id = "17373109";
$app_token = "48148cfca3c...";
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
When I am commenting it line by line it is working till "Podio::authenticate_with_app($app_id, $app_token);" line. So I think the problem is in this line.
Please let me know the solution.
Thanks
Shashank Kumar
You need to create new client (the one mentioned in your code as client_id), also you will have to re-generate app token and re-check app_id. If it still doesn't work, please provide full error message returned from Podio API.

Get Business Information using twitter api

I am trying to get the business information of a registered organization using its Website URL.
I searched in many ways. Now, I had downloaded the Twitter API PHP SDK from github.
From the below link
https://github.com/J7mbo/twitter-api-php
In my index.php page, I have changed my code to
$url = 'https://api.twitter.com/1.1/users/search.json';
$getfield = '?q=Twitter%20API';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
But, it gives me an empty result in the browser.
Please help me in getting some result out of it.
Thanks in advance!
I still didn't find any answer for my question. Now, I had downloaded the Twitter API PHP SDK from github.
From the below link
https://github.com/J7mbo/twitter-api-php
In my index.php page, I have changed my code to
$url = 'https://api.twitter.com/1.1/users/search.json';
$getfield = '?q=Twitter%20API';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
But, it gives me an empty result in the browser.
Please help me in getting some result out of it.
Thanks in advance!
The error message you are receiving tells you the answer:
The Twitter REST API v1 is no longer active. Please migrate to API v1.1.
https://dev.twitter.com/docs/api/1.1/overview
Use the current API not the old one.

Saving information from ios app to web server (POST JSON)

The problem i am having is that i am unable to so save information from my ios application to my web server, I am currently app to retrieve the data using JSON and parsing that data.
I have written the php code for the request and it is stored on my server:
...else
{
// updating record
$q = sprintf("update phone_book set name = '%s', phoneNumber = '%s', email = '%s', phoneNumber = '%s' where name = '%s'",
mysql_real_escape_string($_GET["name"]),
mysql_real_escape_string($_GET["phoneNumber"]),
mysql_real_escape_string($_GET["email"]),
mysql_real_escape_string($_GET["address"]));
}
However I have looked everywhere and am unable to find information on how i could use post this information from my application to the web server.
Would appreciate any help. Thanks!
Use this api for post and get calls and object mapping
https://github.com/RestKit/RestKit
This actually wasent to hard. Another option instead of using REST was to POST JSON from the iOS application sending the JSON to a site where a php file contains the code. The fixed code inside the PHP would look like:
...
$json_post = json_decode(file_get_contents ('php://input'),1);
$name = $json_post['name'];
$phone = $json_post['phone'];
$aQuery = "UPDATE phone_book SET phoneNumber = '$phone' WHERE name = '$name' ";
mysql_query($aQuery);
...
If anyone requires anymore help feel free to leave a comment. Good Luck!

processing application response from apply with linkedin

I am trying to get the response returned by the Apply with LinkedIn plugin. I am using Zend Framework. I have tried using the sample code from linkedIn
<?php
// access raw HTTP POST data
$post_body = file_get_contents('php://input');
$application = json_decode($post_body);
// confirm success by writing applicant name to the error log
error_log($application->person->firstName . " " . $application->person->lastName);
// now parse $application and insert data into a DB
// or perform another action
?>
pasted this in my controller and then my view but no success.
my data-url is the url of the current page...
Could anyone show me how this is suppose to be done PHP or javascript (need to get the response into the database).
Thanks.
Try replacing
$post_body = file_get_contents('php://input');
With:
$post_body = $this->getRequest()->getRawBody();
Where $this refers to the current request. I'm not positive if you get this for free..., but I'm hoping you can take this from here. I'm not a ZF expert.