The following is my script. I am continuously getting an invalid_scope error.
$arr = array(
'file' =>
array(
'name' => 'pdf.pdf',
'source' => 'upload',
),
'document' =>array(
'signer_sequencing' => 'false',
'expires_in' => '12',
'name' => 'Signme',
'roles' =>array(
'name' => 'a',
'signer_email' => 'example#gmail.com',
'signer_name' => 'farqalit',
),
),
'sending_request' =>array(),
);
$post_json = json_encode($arr);
$endpoint = "https://api.rightsignature.com/public/v1/sending_requests?access_token=API_TOKEN";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
Related
I am using this script in PHP to capture google products through ZenSerp. I can get an output with all the terms.
Example;
Title
Description
Price
Image
URL Link
Is there a way to print
1.price
2.title
3.description
on another page?
thanks.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$data = [
"q" => "Tools",
"tbm" => "shop",
"device" => "desktop",
"location" => "Manhattan,New York,United States",
];
curl_setopt($ch, CURLOPT_URL, "https://app.zenserp.com/api/v2/search?" . http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"apikey: XXXX",
));
$response = curl_exec($ch);
curl_close($ch);
$json = json_decode($response);
echo '<pre>' . var_export($json, true) . '</pre>';
?>
Output:
(object) array(
'title' => 'Craftsman 320-Piece Mechanic S Tool Set',
'link' => '/aclk?sa=L&ai=DChcSEwjn5sb54NDtAhXHfysKHWT9BIIYABBXGgJzZg&sig=AOD64_1kzP9frQqO7uULjK4LGcDJkpuuGA&ctype=46&q=&ved=0ahUKEwjP9cL54NDtAhUBjeYKHaqqBzgQ_-QECL8H&adurl=',
'description' => 'Mechanic ยท CRAFTSMAN',
'price' => '$149.99',
'source' => 'Sears',
'stars' => 4.5999999999999996447286321199499070644378662109375,
'reviews' => 1084,
'thumbnail' => 'data:image/jpeg;base64,/',
'extensions' =>
array (
),
'product_id' => '13276029442981215243',
'price_parsed' =>
(object) array(
'currency' => 'USD',
'value' => 149.990000000000009094947017729282379150390625,
I have tried reloadly API stated on their doc but no success, i could not find exactly the correct API end point to make Curl call.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://topups.reloadly.com/accounts/balance
");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: application/com.reloadly.topups-v1+json",
"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik0wWXpRa"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
I got from their their API doc https://topupsapi.docs.apiary.io it stated on sending airtime but no correct endpoint stated. thank
Is there any function or correct endpoint i didn't know about?
the endpoint is https://topups.reloadly.com/topups , and it's supposed to look something like this:
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://topups.reloadly.com/topups',
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => array(
"Accept: application/com.reloadly.topups-v1+json",
"Content-Type: application/json",
"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSU",
),
CURLOPT_POSTFIELDS => json_encode(array(
'recipientPhone' => array(
'countryCode' => 'HT',
'number' => '+50936377111',
),
'senderPhone' => array(
'countryCode' => 'US',
'number' => '+13059547862',
),
'operatorId' => 173,
'amount' => 15,
'customIdentifier' => 'transaction by john#example.com',
))
));
curl_exec($ch);
curl_close($ch);
<?php
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://topups.reloadly.com/topups',
CURLOPT_POST => 1,
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: application/com.reloadly.topups-v1+json",
"Authorization: Bearer your_access_token")),
CURLOPT_POSTFIELDS => json_encode(array(
'recipientPhone' => array(
'countryCode' => 'HT',
'number' => '+50936377111'
),
'senderPhone' => array(
'countryCode' => 'US',
'number' => '+13059547862'
),
'operatorId' => 173,
'amount' => 15,
'customIdentifier' => 'transaction by john#example.com'
))
));
$response = curl_exec($ch);
curl_close($ch);
echo '<pre>';
var_dump($response);
echo '</pre>';
[enter image description here][1]?>
I am using one signal API For push notification. And I want to know how can I send button with value(Confirm = 1, Deny =0) so that I can post it from the notification screen. I am not able to send action button through API t the app. I want to post the value of the action button in the database. Please help
This is my code.
function sendMessage(){
$heading=array(
"en" => 'TEST'
);
$content = array(
"en" => 'TEST.'
);
$hashes_array = array();
array_push($hashes_array, array(
"id" => "1",
"text" => "Confirm",
"icon" => "http://i.imgur.com/N8SN8ZS.png",
"url" => "https://yoursite.com"
));
array_push($hashes_array, array(
"id" => "0",
"text" => "Deny",
"icon" => "http://i.imgur.com/N8SN8ZS.png",
"url" => "https://yoursite.com"
));
$fields = array(
'app_id' => "xxxxxxx-xxxxxxx-45b8-97d4-02982b59c14f",
'include_player_ids' => array($GLOBALS['one_signal_id']),
'data' => array("Status" => 200),
'small_icon' => 'https://lh3.googleusercontent.com/TzYz9McRVy8fD_WnpKiCK5anw20So6eyPR9ti-LwTd_QIer8BpAg8cMkRoO4sUv2xCDw=w300-rw',
'large_icon' => 'https://lh3.googleusercontent.com/TzYz9McRVy8fD_WnpKiCK5anw20So6eyPR9ti-LwTd_QIer8BpAg8cMkRoO4sUv2xCDw',
'headings' => $heading,
'contents' => $content,
'web_buttons' => $hashes_array
);
$fields = json_encode($fields);
// print("\nJSON sent:\n");
// print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
'Authorization: Basic xxxxxxxxxxxxxxxxxxxxxx5NjktMjRkZWM0ZjFhMjZl'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = sendMessage();
I wanna add user to OneSignal with API for push-msg. Its possible ? If yes - how to ?
thanks for answers
my code return "No Push Token" and i dont't khow how to fix this problem
<?
$fields = array(
'app_id' => "",
'language' => "ru",
'timezone' => "-28800",
'device_type' => "5",
);
$fields = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/players");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
$return["allresponses"] = $response;
$return = json_encode( $return);
print($return);
?>
https://documentation.onesignal.com/reference#create-notification
https://documentation.onesignal.com/reference#section-example-code-create-notification
Go through the sample code given there.
This is for Sending to all subscribers :
function sendMessage() {
$content = array(
"en" => 'English Message'
);
$hashes_array = array();
array_push($hashes_array, array(
"id" => "like-button",
"text" => "Like",
"icon" => "http://i.imgur.com/N8SN8ZS.png",
"url" => "https://yoursite.com"
));
array_push($hashes_array, array(
"id" => "like-button-2",
"text" => "Like2",
"icon" => "http://i.imgur.com/N8SN8ZS.png",
"url" => "https://yoursite.com"
));
$fields = array(
'app_id' => "5eb5a37e-b458-11e3-ac11-000c2940e62c",
'included_segments' => array(
'All'
),
'data' => array(
"foo" => "bar"
),
'contents' => $content,
'web_buttons' => $hashes_array
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
For specific segments:
$fields = array(
'app_id' => "5eb5a37e-b458-11e3-ac11-000c2940e62c",
'included_segments' => array('Active Users'),
'data' => array("foo" => "bar"),
'contents' => $content
);
For Onesignal player IDs:
$fields = array(
'app_id' => "5eb5a37e-b458-11e3-ac11-000c2940e62c",
'include_player_ids' => array("6392d91a-b206-4b7b-a620-cd68e32c3a76","76ece62b-bcfe-468c-8a78-839aeaa8c5fa","8e0f21fa-9a5a-4ae7-a9a6-ca1f24294b86"),
'data' => array("foo" => "bar"),
'contents' => $content
);
Alright, i have searched this and many more forums, no solution for me.
I have this code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $this->auth['access_token']
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array(
'intent' => 'sale',
'redirect_urls' => array(
'return_url' => 'http://andershagbard.wep.dk/goingpro/',
'cancel_url' => 'http://andershagbard.wep.dk/goingpro/'
),
'payer' => array (
'payment_method' => 'paypal'
),
'transactions' => array(
'amount' => array(
'total' => '5.00',
'currency' => 'USD'
),
'description' => 'This is the payment transaction description.'
)
)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
And it returns
(
[name] => MALFORMED_REQUEST
[message] => Incoming JSON request does not map to API request
[information_link] => https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST
[debug_id] => 27f7487f9c07f