Calling curl URL in android - android

Let me directly come to the point.
I have one curl url like below
curl https://api.start.payfort.com/tokens/ \
-u test_open_k_1741a9b51afbb3a986f2: \
-d "number=4242424242424242" \
-d "exp_month=11" \
-d "exp_year=2016" \
-d "cvc=123" \
-d "name=Abdullah Mohammed"
I am not pretty good with curl URL calling.
I want to call this URL in android how can I pass header in Android in this example?
Any help would be highly appreciated.

Related

Curl in Android HERE Maps

How can I implement curl command in Android? I am using https://places.cit.api.here.com/places/v1/autosuggest?app_id=appid&app_code=appcode&at=52.5304417,13.4111201&q=rest&pretty but it does not return JSON file. It returns an HTML page.I want to do search on the maps and show nearby restaurants.
curl \
--compressed \
-H 'Accept-Encoding:gzip' \
-H 'Accept-Language:en-US,en;q=0.5' \
--get 'https://places.cit.api.here.com/places/v1/autosuggest' \
--data-urlencode 'app_code=appcode' \
--data-urlencode 'app_id=appid' \
--data-urlencode 'at=52.5304417,13.4111201' \
--data-urlencode 'pretty=true' \
--data-urlencode 'q=rest'
Please note that you've just published your app id and app code publicly. They are very likely going to be abused. You should probably delete the project associated with these credentials and create a new one to prevent this.

Unable to upload an APK file to hockey app via their API

I am unable to upload an android apk to hockeyapp through the API provided by them.When i use
curl \ -F "status=2" \
-F "notify=1" \
-F "notes=Some new features and fixed bugs." \
-F "notes_type=0" \
-F "apk=#app-release.apk" \
-H "X-HockeyAppToken: MY_TOKEN" \https://rink.hockeyapp.net/api/2/apps/MY_APP_ID/app_versions/upload
i am getting an error : {"status":null}
And when I try
curl \
-F "status=2" \
-F "notify=1" \
-F "notes=Some new features and fixed bugs." \
-F "notes_type=0" \ -F "apk=#app-release.apk" \
-H "X-HockeyAppToken: MY_TOKEN" \ https://rink.hockeyapp.net/api/2/apps/upload
an error occurs : {"status":"error","message":"File not found. Please check that your file is not a directory or bundle."}
Please give me a solution.Drag and drop is working for me.But I need it to be done through their API.I am using Team City as my CI server.
The parameter for the build is called "ipa" on all platforms, i.e. -F "ipa=#app-release.apk" would be correct.

Apache Cordova Android Push Notification Aerogear Unable To Send

While using
curl -3 -u \
"f07c43a6-bb0a-4bb7-a1eb-a368db272212:e2cf19c3-6636-4712-bbe8-26b7c1ac9c09" \
-v -H "Accept: application/json" -H "Content-type: application/json" \
-X POST -d '{"message": {"alert":"Hello AeroGear", "badge":1}}' \
https://aerogear-html5.rhcloud.com/rest/sender
to push notification
I am getting 401 unauthorised request.Unable to figure out how to authenticate?
Make sure your authorization parameters(through -u) are valid and also make sure you are using the correct credential for the service you are trying to access.
Also, if you are from windows(for linux its ok) then wrap the post parameters with double quotes(") Instead of single(').
-d "{\"message\": {\"alert\":\"Hello AeroGear\", \"badge\":1}}"
Going to this link https://aerogear-html5.rhcloud.com, produces a website not available
Is there a specific tutorial you used to get that curl command?

Why libclcore in directory "host" in android 4.4 source code not update like target?

Now I want to add a function into RenderScript to support a new interface by myself.
I wrote the code and add myFunc.c file into "android-4.4-src/frameworks/rs/driver/runtime/", and modify Android.mk(append myFunc.c to clcore_base_files at line 20):
clcore_base_files := \
rs_allocation.c \
rs_cl.c \
rs_core.c \
rs_element.c \
rs_mesh.c \
rs_matrix.c \
rs_program.c \
rs_sample.c \
rs_sampler.c \
convert.ll \
allocation.ll \
rsClamp.ll \
myFunc.c
Then add myFunc.rsh into "android-4.4-src/frameworks/rs/scriptc/", and include myFunc.rsh in rs_core.rsh which in the same directory:
#include "myFunc.rsh"
And then I rebuild:
$ source build/envsetup.sh
$ lunch sdk-eng
$ make sdk
The weird thing is: libclcore.bc in "out/target/product/generic/system/lib/" is the new version which contains the function I wrote, but the libclcore.bc in "out/host.linux-x86/sdk/androidXXX/build-tools/android-4.4.3.2xxx/renderscript/lib" is the old version.
I want to update the old version in "host" like the one in "target" when rebuild.
Is there some configurations I forgot?
Any suggestions would be appreciated!

How to stream to ffserver from android

I need to stream from an android camera/ file to a remote ffserver which will broadcast my video. I can do this on the desktop in ubuntu by issuing a command like:
ffmpeg -f video4linux2 -s 640x480 -r 25 -i /dev/video0 http://192.168.0.20:8090/cam1.ffm
or stream a file like this:
ffmpeg -i /home/kev/share/movie.mp4 http://192.168.0.20:8090/cam1.ffm
So basically i want to be able to do the above from android. After several searches this is what i've done so far - i came across this link http://bambuser.com/opensource from which i downloaded the ffmpeg source and built it. The build outputs several things:
1. shared libs [libavcodec, libavcore, libavdevice, libavfilter,libavformat,libavutil,libswscale]
2. executables [ffmpeg,ffprobe]
Not sure how to plug my functionality with these resources this is what i've tried so far:
1. loaded the libs in my Activity using System.loadLibrary() then copied the ffmpeg executable to the assets folder which at runtime i copied to my application's "files" directory i then set permissions for the executable using Runtime.getRuntime().exec(). then the last step was to execute it in java with the following statement:
Runtime.getRuntime().exec("ffmpeg -i file:///android_asset/movie.mp4http://<server>:8090/cam1.ffm");
2. copied ffmpeg.c,the shared libraries and the "include" folder that was generated by the build to my jni folder and added a jni function that wraps around the main() function in ffmpeg.c. With this approach i've found myself having to copy several header files from the ffmpeg source for the ndk-build to succeed and i highly doubt if this is the way to go.
The above two approaches havnt worked for me, i'm not sure where i'm going wrong, so any help on how to do a simple ffmpeg streaming like an mp4 file from android would be highly appreciated.
I got it working by using apporach 2, this is what i did.
1. copied ffmpeg.c,the "include" folder and the shared libraries to my project's jni folder.
modified ffmpeg.c with reference to this blog post http://demo860.blogspot.com/2010/07/android-ffmpeg-dynamic-module-jni.html
there were several errors while building with ndk so i just added the missing dependencies until finally the build succeeded.
At first the app would start and then immediately exit, this was due to a couple of things i forgot to do so make sure you've done the following to save yourself some hours and hair loss:
- set internet permission on manifest(if media file is in sdcard, set write external storage permission and make sure the sdcard is mounted)
- make sure the remote ffserver is running and configured correctly. you can confirm by streaming from a desktop
- make sure you have the correct params passed
Now i can stream from an mp4 file in my sdcard to a remote ffserver, havnt tried streaming from the device camera yet.
It seems to be a bit late to answer this question, but if you need a solution, here's one...
Well, I had devised a workaround to the same problem but through the first approach that is using a compiled FFmpeg Binary rather than JNI...
First, as far as it seems to me, the builds provided by Bambuser are way too old and FFmpeg has a vicious development cycle...
So I'd rather suggest to custom build your own binary from the latest FFmpeg Source...
Here's a script that could be used to generate one :
#!/bin/bash
echo ""
echo " ********** FFmpeg Android Build ********** "
echo ""
NDK=$HOME/android-ndk-r8d
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
PLATFORM=$NDK/platforms/android-14/arch-arm
PREFIX=$HOME/FFmpeg.Binaries.Android
FFMPEG_BASE=$HOME/FFmpeg.Build
if [ -d "$FFMPEG_BASE" ]; then
rm -v -r -f $FFMPEG_BASE
fi
if [ -d "$PREFIX" ]; then
rm -v -r -f $PREFIX
fi
mkdir $FFMPEG_BASE
mkdir $PREFIX
# x264 Installation
echo ""
echo " ********** libx264 Installation ********** "
echo ""
cd $FFMPEG_BASE
git clone --depth 1 git://git.videolan.org/x264
cd $FFMPEG_BASE/x264
./configure --prefix=$PREFIX \
--enable-static \
--enable-pic \
--disable-asm \
--disable-cli \
--host=arm-linux \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--sysroot=$PLATFORM
make
sudo make install
sudo ldconfig
#FFmpeg Installation
echo ""
echo " ********** FFmpeg (Android) Installation ********** "
echo ""
cd $FFMPEG_BASE
# git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd $FFMPEG_BASE/ffmpeg
./configure --target-os=linux --prefix=$PREFIX \
--enable-cross-compile \
--enable-runtime-cpudetect \
--disable-asm \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--disable-stripping \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--enable-nonfree \
--enable-version3 \
--enable-gpl \
--disable-doc \
--enable-avresample \
--enable-demuxer=rtsp \
--enable-muxer=rtsp \
--disable-ffserver \
--disable-ffprobe \
--enable-ffmpeg \
--enable-ffplay \
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=h264 \
--enable-protocol=rtp \
--enable-hwaccels \
--enable-zlib \
--extra-cflags="-I$PREFIX/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
--extra-ldflags="-L$PREFIX/lib"
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$PREFIX/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
# rm -v -r -f $FFMPEG_BASE
clear
echo ""
echo "FFmpeg Android Build Successful..."
echo ""
ls -l -R $PREFIX
exit
For the above script to work, Android NDK is required and could be downloaded from here. Download the NDK and extract to your /home/<username> directory or else customize the script as per your needs...
And also avoid using the file:// protocol in the command line, just specify the absolute path of the input file. And try to log the output from the FFmpeg process by gettin' instances of its stdout and stderr streams...
You don't have to copy shared libraries and include folder. You can use the "PREBUILD_SHARED_LIBRARY" feature of Andriod.mk instead.

Categories

Resources