Comments on: Code Samples https://docs.appfigures.com App Store API Documentation Tue, 25 Sep 2018 08:51:00 +0000 hourly 1 https://wordpress.org/?v=4.8.26 By: Cody Crumrine https://docs.appfigures.com/code-samples#comment-228 Wed, 13 Sep 2017 18:48:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-228 Here you go:

“`
ini_set(‘display_errors’,1);
error_reporting(E_ALL);
session_start();
function getFullHost($s){
$ssl = (!empty($s[‘HTTPS’]) && $s[‘HTTPS’] == ‘on’) ? true:false;
$sp = strtolower($s[‘SERVER_PROTOCOL’]);
$protocol = substr($sp, 0, strpos($sp, ‘/’)) . (($ssl) ? ‘s’ : ”);
$port = $s[‘SERVER_PORT’];
$port = ((!$ssl && $port==’80’) || ($ssl && $port==’443′)) ? ” : ‘:’.$port;
$host = isset($s[‘HTTP_X_FORWARDED_HOST’]) ? $s[‘HTTP_X_FORWARDED_HOST’] : isset($s[‘HTTP_HOST’]) ? $s[‘HTTP_HOST’] : $s[‘SERVER_NAME’];
return $protocol . ‘://’ . $host . $port . $s[‘REQUEST_URI’];
}

define(“BASE_URL”, ‘https://api.appfigures.com/v2/’);
define(“CLIENT_KEY”,’YOUR CLIENT KEY’);
define(“CLIENT_SECRET”,’YOUR CLIENT SECRET’);

if(isset($_REQUEST[‘oauth_token’]) && isset($_REQUEST[‘oauth_verifier’])){ //we’ve got a token back
$oauth_sig = “OAuth oauth_signature_method=PLAINTEXT”
. ‘, oauth_verifier=’ . $_REQUEST[‘oauth_verifier’]
. ‘, oauth_token=’ . $_REQUEST[‘oauth_token’]
. “, oauth_consumer_key=” . CLIENT_KEY
. “, oauth_signature=” . CLIENT_SECRET . ‘&’ . $_SESSION[‘request_secret’];
$ch = curl_init(BASE_URL . ‘oauth/access_token’);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Authorization: ‘ . $oauth_sig
));
$response = curl_exec($ch);
parse_str($response, $result);
var_dump($result);
die();
}else{ //we need to redirect the user to the auth dialog
$oauth_sig = “OAuth oauth_signature_method=PLAINTEXT”
. “, oauth_consumer_key=” . CLIENT_KEY
. “, oauth_callback=” . getFullHost($_SERVER)
. “, oauth_signature=” . CLIENT_SECRET . ‘&’;
$ch = curl_init(BASE_URL . ‘oauth/request_token’);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Authorization: ‘ . $oauth_sig
));
$response = curl_exec($ch);
parse_str($response, $result);
if(!isset($result[‘oauth_token’])){
var_dump($response);
throw new Exception(‘Error, did not receive an oauth request token.’, 1);
}
$request_token = $result[‘oauth_token’];
$_SESSION[‘request_secret’] = $result[‘oauth_token_secret’];

header('Location: ' . BASE_URL . '/oauth/authorize/?oauth_token=' . $request_token);

}
“`

]]>
By: Gunt https://docs.appfigures.com/code-samples#comment-206 Mon, 20 Jun 2016 14:06:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-206 2 years and no PHP exampe?:)

]]>
By: Benny Elgazar https://docs.appfigures.com/code-samples#comment-170 Wed, 01 Jul 2015 08:18:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-170 Hey, How do I get the access_token without automaticly without enter manualy to the site each time and the past it to my python code??

]]>
By: ElieH https://docs.appfigures.com/code-samples#comment-154 Fri, 20 Mar 2015 12:20:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-154 PHP example :

$ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://api.appfigures.com/v2/");
    curl_setopt($ch, CURLOPT_TIMEOUT, 200);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    //might help if running on localhost 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
          "X-Client-Key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      ));

    curl_setopt($ch, CURLOPT_USERPWD, "USERNAME:PASSWORD");
    $response = curl_exec($ch);
    curl_close($ch);

   echo $response;

]]>
By: Ronen Magid https://docs.appfigures.com/code-samples#comment-153 Thu, 12 Mar 2015 15:17:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-153 Node.JS?

]]>
By: Heezze https://docs.appfigures.com/code-samples#comment-136 Sun, 16 Nov 2014 10:34:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-136 No PHP example? :/ I do PHP and do not understand how to do oAuth.
Will you do a oAuth example soon?

]]>
By: Guest https://docs.appfigures.com/code-samples#comment-126 Tue, 07 Oct 2014 21:49:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-126 Great example .. Thank You!

]]>
By: Patrice https://docs.appfigures.com/code-samples#comment-105 Tue, 22 Jul 2014 15:28:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-105 Java examples would also be a big help for us.

]]>
By: J. Justin Hancock https://docs.appfigures.com/code-samples#comment-102 Tue, 15 Jul 2014 20:50:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-102 How about a Java example?

]]>
By: appfigures https://docs.appfigures.com/code-samples#comment-93 Fri, 11 Jul 2014 21:13:00 +0000 http://docs.appfigures.com/?page_id=1084#comment-93 We don’t have any at the moment but code samples in other languages will be available in the future.

]]>